I want to use vulkan for pytorch module in android

When loading a module
mModule = Module.load(assetFilePath(context, “vulkan.pt”), Device.VULKAN)

to do this

1.7 version in android studio
implementation ‘org.pytorch:pytorch_android:1.7.0’
implementation ‘org.pytorch:pytorch_android_torchvision:1.7.0’
I did.

outputTuple = mModule!!.forward(IValue.from(inputTensor)).toTuple()
An error occurs during forwarding.

the error message is
com.facebook.jni.CppException: PyTorch is not linked with support for vulkan devices
Exception raised from getDeviceGuardImpl at … /c10/core/impl/DeviceGuardImplInterface.h:216 (most recent call first):

This is it.


Hi @user21 ,

  1. Can you check if the .so files that you have are vulkan compatible?
    If not then create a Vulkan compatible PyTorch Android libs
  2. Make sure .pt file is generated by providing backend=‘vulkan’ during export