[Vulkan][Android] Loader of vulkan(module.loadlibrary_vulkan) is not presented


#1

Hi,

Trying to run android_deploy.py with Vulkan backend, I get the error (from the logcat):

05-08 15:28:54.937 17521 17587 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
05-08 15:28:54.937 17521 17587 E AndroidRuntime: Process: ml.dmlc.tvm.android.demo, PID: 17521
05-08 15:28:54.937 17521 17587 E AndroidRuntime: java.lang.RuntimeException: An error occurred while executing doInBackground()
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at android.os.AsyncTask$3.done(AsyncTask.java:318)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:242)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at java.lang.Thread.run(Thread.java:762)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: Caused by: ml.dmlc.tvm.Base$TVMError: TVMError: Check failed: f != nullptr: Loader of vulkan(module.loadbinary_vulkan) is not presented.
05-08 15:28:54.937 17521 17587 E AndroidRuntime: Stack trace:
05-08 15:28:54.937 17521 17587 E AndroidRuntime: File “/home/SERILOCAL/n.perto/Documents/tvm/apps/android_deploy/app/src/main/jni/…/…/…/…/…/…/include/…/src/runtime/module_util.cc”, line 55
05-08 15:28:54.937 17521 17587 E AndroidRuntime:
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at ml.dmlc.tvm.Base.checkCall(Base.java:173)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at ml.dmlc.tvm.Function.invoke(Function.java:130)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at ml.dmlc.tvm.Module.load(Module.java:140)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at ml.dmlc.tvm.Module.load(Module.java:146)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at ml.dmlc.tvm.android.demo.MainActivity$LoadModleAsyncTask.doInBackground(MainActivity.java:230)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at ml.dmlc.tvm.android.demo.MainActivity$LoadModleAsyncTask.doInBackground(MainActivity.java:158)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:304)
05-08 15:28:54.937 17521 17587 E AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:237)

When compiling the module (using the example from deploy_model_on_mali_gpu.py, I also get an error and it seems that the problem come from this:

WARNING:autotvm:Cannot find config for target=vulkan, workload=('dense', (1, 512, 'float32'), (1000, 512, 'float32'), (1000, 'float32'), 0). A fallback configuration is used, which may bring great performance regression.
[15:37:09] /home/SERILOCAL/n.perto/Documents/tvm/src/runtime/vulkan/vulkan_device_api.cc:693: Cannot initialize vulkan: [15:37:09] /home/SERILOCAL/n.perto/Documents/tvm/src/runtime/vulkan/vulkan_device_api.cc:531: Check failed: __e == VK_SUCCESS: Vulan Error, code=-9: VK_ERROR_INCOMPATIBLE_DRIVER
Stack trace:
  [bt] (0) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x9ecaf0) [0x7fe4b793faf0]
  [bt] (1) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x9f2c02) [0x7fe4b7945c02]
  [bt] (2) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x9fb392) [0x7fe4b794e392]
  [bt] (3) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x8f729b) [0x7fe4b784a29b]
  [bt] (4) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x27931f) [0x7fe4b71cc31f]
  [bt] (5) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x2957fe) [0x7fe4b71e87fe]
  [bt] (6) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x1b4cce) [0x7fe4b7107cce]
  [bt] (7) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(TVMFuncCall+0x61) [0x7fe4b78c44c1]
  [bt] (8) /home/SERILOCAL/n.perto/.anaconda3/envs/tf/lib/python3.6/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c) [0x7fe4ba95cec0]


You can still compile vulkan module but cannot run locally

What does this exactly mean?

Edit: I am linking with toolchain’s vulkan library libvulkan.so, from what I have understood this should contain the loader…
The library is present on the device, it runs on android API 24 64-bit.

Edit 2: I did some inspection of the intermediate objects generated for the construction of the apk, I can see that InitVulkan() is present (like in build/intermediates/jniLibs/release/arm64-v8a/libtvm4j_runtime_packed.so).
I am also able to run vulkan sample apps (no TVM inside), so vulkan is working on the device.


#2

After changing the version of the headers (I was using v1.1 but android version is 7 so it runs Vulkan 1.0), it seems to work, I can run the tutorial deploy model on android with vulkan target.

I still get quirk messages when compiling the module:

[16:40:02] /home/SERILOCAL/n.perto/Documents/tvm/src/runtime/vulkan/vulkan_device_api.cc:693: Cannot initialize vulkan: [16:40:02] /home/SERILOCAL/n.perto/Documents/tvm/src/runtime/vulkan/vulkan_device_api.cc:531: Check failed: __e == VK_SUCCESS: Vulan Error, code=-9: VK_ERROR_INCOMPATIBLE_DRIVER
Stack trace:
  [bt] (0) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0xa20290) [0x7f78744bc290]
  [bt] (1) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0xa263a2) [0x7f78744c23a2]
  [bt] (2) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0xa2eb32) [0x7f78744cab32]
  [bt] (3) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x91bceb) [0x7f78743b7ceb]
  [bt] (4) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x27d1af) [0x7f7873d191af]
  [bt] (5) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x29968e) [0x7f7873d3568e]
  [bt] (6) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(+0x1b8c6e) [0x7f7873c54c6e]
  [bt] (7) /home/SERILOCAL/n.perto/Documents/tvm/build/libtvm.so(TVMFuncCall+0x61) [0x7f7874430e31]
  [bt] (8) /home/SERILOCAL/n.perto/.anaconda3/envs/tf/lib/python3.6/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c) [0x7f7893487ec0]


You can still compile vulkan module but cannot run locally
TVM prediction top-1: tiger cat
Evaluate inference time cost...
Mean inference time (std dev): 1232.63 ms (1.90 ms)

Is it be because I have vulkan version 1.1 installed on my linux system and the device is using vulkan 1.0?

Edit: When trying to run with android_deploy app I also get the Loader of vulkan(module.loadbinary_vulkan) is not presented., so I think that I was wrong, I did not managed to run vulkan modules.