android-demo-app icon indicating copy to clipboard operation
android-demo-app copied to clipboard

HellowWorld app immediately crashes on launch

Open phildow opened this issue 4 years ago • 3 comments

With a clone of the repo as of Aug 14, 2020, no modifications, the HelloWorld app crashes at launch trying to read the model.pt asset:

/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.pytorch.helloworld, PID: 6473
    java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.helloworld/org.pytorch.helloworld.MainActivity}: com.facebook.jni.CppException: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at ../caffe2/serialize/inline_container.cc:132, please report a bug to PyTorch. Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 2. Your PyTorch installation may be too old. (init at ../caffe2/serialize/inline_container.cc:132)
    (no backtrace available)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: com.facebook.jni.CppException: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at ../caffe2/serialize/inline_container.cc:132, please report a bug to PyTorch. Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 2. Your PyTorch installation may be too old. (init at ../caffe2/serialize/inline_container.cc:132)

The crash is consistent even if I recreate the model with the trace_model script using a couple different versions of torch and torchvision:

With torch==1.6.0 torchvision==0.7.0, Run python trace_model.py, clean and launch, app crashes with same error.

With torch==1.4.0 torchvision==0.5.0, Run python trace_model.py, clean and launch, app crashes with same error.

It may be worth noting that I have multiple versions of the Android NDK installed and specify ndkVersion "21.1.6352462"

phildow avatar Aug 14 '20 19:08 phildow

I got the same error and was able to fix the problem by updating the dependencies. See my repo (https://github.com/suyashjoshi/android-demo-app) for this fixed version. I've also submitted a Pull Request to the main Android PyTorch repo with the fix : https://github.com/pytorch/android-demo-app/pull/87

suyashcjoshi avatar Oct 25 '20 20:10 suyashcjoshi

Hello @suyashjoshi Can you help me , I am trying to load my custom model (xyz.pth) using the script trace_model.py but getting this error Is my model loading is correct ? what should I do please help ............ image

Siddhijain16 avatar Dec 30 '20 08:12 Siddhijain16

I'm facing this error as well. This is really off-putting when a Hello World for a noob :(

jasoriya avatar Jun 25 '21 03:06 jasoriya