Pytorch mobile deployment

Hi. I am using pytorch 1.5.0. I have put gradle dependency as

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'org.pytorch:pytorch_android:1.4.0'
    implementation 'org.pytorch:pytorch_android_torchvision:1.4.0'

}

I trained my model on CPU and used this script to export

model_ft.eval()
example = torch.rand(1, 3, 224, 224)
traced_script_module = torch.jit.trace(model_ft, example)
traced_script_module.save("model_res.pt")

When I run the detection in android, it shows

Process: com.example.pytorchmobile, PID: 7756
    com.facebook.jni.CppException: empty_strided not implemented for DispatchKeySet(BackendSelect, CUDATensorId) (empty_strided at aten/src/ATen/Functions.h:4051)
    (no backtrace available)

Please HELP ME.

1 Like