Android Vulkan GPU intialization error while running through RPC

Am trying to compile tvm add operation with target=“vulkan” and target_host=“llvm -target=arm64-linux-android” and trying to load on android phone (Mate 9), faced VK_ERROR_INITIALIZATION_FAILED .

RPC terminal error:

You can still compile vulkan module but cannot run locally Run GPU test … Traceback (most recent call last): File “tests/android_rpc_test.py”, line 101, in test_rpc_module() File “tests/android_rpc_test.py”, line 84, in test_rpc_module f1(a,b) File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/_ffi/function.py”, line 128, in call return f(*args) File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/_ffi/_ctypes/function.py”, line 183, in call ctypes.byref(ret_val), ctypes.byref(ret_tcode))) File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/_ffi/base.py”, line 66, in check_call raise TVMError(py_str(_LIB.TVMGetLastError())) tvm._ffi.base.TVMError: Except caught from RPC call: [18:04:46] /home/User/shared-windows7/work_nnvm/work_tvm/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/module_util.cc:52: Check failed: ret == 0 (-1 vs. 0) [18:04:46] /home/User/shared-windows7/work_nnvm/work_tvm/apps/android_rpc/app/src/main/jni/../../../../../../include/../src/runtime/vulkan/vulkan_module.cc:218: Check failed: __e == VK_SUCCESS Vulan Error, code=-3: VK_ERROR_INITIALIZATION_FAILED

Android ADB Logcat :

07-06 18:02:46.048 31598 31617 W System.err: libtvm4j loads successfully.
07-06 18:02:46.066 31598 31617 W System.err: Load module from /data/user/0/ml.dmlc.tvm.tvmrpc/cache/tvm4j_rpc_1118655590/dev_lib.so
07-06 18:02:46.068 31598 31617 D vulkan_module.cc: module.loadbinary_vulkan enter
07-06 18:02:46.069 31598 31617 D vulkan_module.cc: VulkanModuleLoadBinary enter
07-06 18:02:46.069 31598 31617 D vulkan_module.cc: Load enter
07-06 18:02:46.069 31598 31617 D vulkan_module.cc: VulkanModuleCreate enter source:
07-06 18:02:46.069 31598 31617 D vulkan_device_api.cc: Global enter
07-06 18:02:46.069 31598 31617 D vulkan_device_api.cc: Init enter, initialized_=0
07-06 18:02:46.069 31598 31617 D vulkan_device_api.cc: CreateInstance enter
07-06 18:02:46.071 31598 31617 D vulkan  : searching for layers in '/data/app/ml.dmlc.tvm.tvmrpc-2/lib/arm64'
07-06 18:02:46.071 31598 31617 D vulkan  : searching for layers in '/data/app/ml.dmlc.tvm.tvmrpc-2/base.apk!/lib/arm64-v8a'
07-06 18:02:46.136 31598 31617 D vulkan_device_api.cc: GetContext enter
07-06 18:02:46.165 31598 31617 D vulkan_device_api.cc: FindMemoryTypeIndex enter
07-06 18:02:46.165 31598 31617 D vulkan_device_api.cc: Initialzie Vulkan with 1 devices..
07-06 18:02:46.166 31598 31617 D vulkan_device_api.cc: vulkan(0)='Mali-G71' phy_dev_id=0x758a335028
07-06 18:02:46.201 31598 31617 D vulkan_device_api.cc: device_api.vulkan enter
07-06 18:02:46.202 31598 31617 D vulkan_device_api.cc: Global enter
07-06 18:02:46.202 31598 31617 D vulkan_device_api.cc: AllocDataSpace enter
07-06 18:02:46.202 31598 31617 D vulkan_device_api.cc: Init enter, initialized_=1
07-06 18:02:46.268 31598 31617 D vulkan_device_api.cc: CopyDataFromTo enter
07-06 18:02:46.268 31598 31617 D vulkan_device_api.cc: Init enter, initialized_=1
07-06 18:02:46.269 31598 31617 D vulkan_device_api.cc: Global enter
07-06 18:02:46.269 31598 31617 D vulkan_device_api.cc: CommandPool enter
07-06 18:02:46.269 31598 31617 D vulkan_device_api.cc: Global enter
07-06 18:02:46.269 31598 31617 D vulkan_device_api.cc: VulkanCommandPool enter
07-06 18:02:46.271 31598 31617 D vulkan_device_api.cc: Alloc enter
07-06 18:02:46.271 31598 31617 D vulkan_device_api.cc: StagingBuffer enter
07-06 18:02:46.273 31598 31617 D vulkan_device_api.cc: Global enter
07-06 18:02:46.283 31598 31617 D vulkan_device_api.cc: AllocDataSpace enter
07-06 18:02:46.283 31598 31617 D vulkan_device_api.cc: Init enter, initialized_=1
07-06 18:02:46.288 31598 31617 D vulkan_device_api.cc: CopyDataFromTo enter
07-06 18:02:46.288 31598 31617 D vulkan_device_api.cc: Init enter, initialized_=1
07-06 18:02:46.288 31598 31617 D vulkan_device_api.cc: CommandPool enter
07-06 18:02:46.288 31598 31617 D vulkan_device_api.cc: Alloc enter
07-06 18:02:46.288 31598 31617 D vulkan_device_api.cc: StagingBuffer enter
07-06 18:02:46.288 31598 31617 D vulkan_device_api.cc: Global enter
07-06 18:02:46.294 31598 31617 D vulkan_module.cc: GetFunction enter name:__tvm_set_device
07-06 18:02:46.294 31598 31617 D vulkan_device_api.cc: SetDevice enter
07-06 18:02:46.295 31598 31617 D vulkan_module.cc: GetFunction enter name:myadd__kernel0
07-06 18:02:46.295 31598 31617 D vulkan_device_api.cc: Global enter
07-06 18:02:46.295 31598 31617 D vulkan_module.cc: operator enter 
07-06 18:02:46.295 31598 31617 D vulkan_module.cc: GetPipeline enter func_name:myadd__kernel0, num_pack_args:0
07-06 18:02:46.295 31598 31617 D vulkan_device_api.cc: Global enter
07-06 18:02:46.295 31598 31617 D vulkan_module.cc: GetPipeline vkCreateComputePipelines,  pe.shader:0x758a331c18 pe.pipeline_layout:0x758a3224b8
07-06 18:02:46.441 31598 31617 D vulkan_device_api.cc: FreeDataSpace enter
07-06 18:02:46.445 31598 31617 D vulkan_device_api.cc: FreeDataSpace enter

How to fix this problem in TVM?

Note : Vulkan indipendant compute operation on same GPU is success

@merrymercy @yidawang

any suggestion/direction where to look on Vulkan for this problem, because am beginner on Vulkan :slight_smile:

I personally do not have experience on Vulkan.

We haven’t yet started to look into vulkan on mobile phone, would be great if you can take a bit deeper look. One possible way is to do a bit tweaks around the APIs and see the difference between this and the simple compute example.

https://github.com/dmlc/tvm/pull/1426 might be related

@tqchen

yes PR 1426 Vulkan able to run on Android phone, PR 1439 contributed to solve #1067.