How to tune vulkan target for mobile phones?


#1

TVMError: [17:09:00] /home/hower/work/tvm/src/codegen/codegen.cc:27: Check failed: bf != nullptr Target vulkan is not enabled

it seems that I should enable vulkan runtime on PC.

but I setup the vulkan sdk, it always enable the local vulkan device during the tuning process.

What should I do?


#2

@howave, I can share my experience with vulkan and TVM on x64 Linux.

  1. Install Vulkan driver on your machine.
    a. AMD GPU https://github.com/GPUOpen-Drivers/AMDVLK
    b. NVIDIA GPU https://developer.nvidia.com/vulkan-driver
  2. Install vulkan SDK.
    https://vulkan.lunarg.com/doc/view/1.1.85.0/linux/getting_started.html
  3. Install Vulkan toolchain.
    https://github.com/KhronosGroup/SPIRV-Tools install it to $VULKAN_SDK path.
  4. Build TVM with Vulkan support.
    cmake -DUSE_LLVM=ON -DUSE_VULKAN=ON …
    make
  5. Run tests.
    $python tvm/tests/python/unittests/test_codegen_device.py

#3

Do you use rpc model to tune the phone?


#4

Thanks for sharing your experience, but I need to tune vulkan device for mobile phone.


#5

Yes, when I tuning with the android rpc app, the rk3399 gpu tuning script run vulkan target locally, and the Gflops of remote rpc always be 0.


#6

@howave, by the way, as I can see at the log you provided

17:09:00] /home/hower/work/tvm/src/codegen/codegen.cc:27: Check failed: bf != nullptr Target

you are compiling on your host, and an error is in the codegen part, so you need to enable vulkan support in TVM.


#7

Yes, I also tried enable vulkan runtime support, but the tuning script or model convertion script always init the vulkan device on my PC


#8

@howave, sorry, but I’m not really sure what you mean by

Yes, I also tried enable vulkan runtime support, but the tuning script or model convertion script always init the vulkan device on my PC

but to be able generate spirv code, you need to enable vulkan support in TVM, to do that you have to rebuild TVM with -DUSE_VULKAN=ON.
I hope it will help.
Thanks.


#9

If you see tvm prints the init message about the vulkan on your PC, that may not be a problem. Even if tvm runs vulkan code on remote devices, some log will be printed. (You can disable the log in c++ files)

You can check whether the GFLOPS makes sense, or use other monitor tools to check whether the code runs on the remote devices.