Error ocurs when I call Module module = LiteModuleLoader.load(assetFilePath(this, "ScriptMod.pth"));
I had also tried Module module = Module.load(assetFilePath(this, "ScriptMod.pth"));
It complains
com.facebook.jni.CppException: PytorchStreamReader failed locating file bytecode.pkl: file not found () Exception raised from valid at ../caffe2/serialize/inline_container.cc:157 (most recent call first):
(no backtrace available)
I have no idea about it. anyone could help?
the modle file “ScriptMod.pth” is about 270kbs, I had doubted its size. but AI team explains that the model size
of HelloWorldApp is large due to image process.
the modle is generated this way:
dummpy_input = copy.deepcopy(trans_tensor(x_test[:256, :]))
ScriptMod = torch.jit.trace(Mod, dummpy_input)
MobOptMod = optimize_for_mobile(ScriptMod)
# Mobile lite
MobOptMod._save_for_lite_interpreter('./online/MobScriptMod.ptl')
# Mobile
ScriptMod.save('./online/ScriptMod.pth')
2022-02-15 16:36:00.492 29338-29338/org.pytorch.helloworld E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.pytorch.helloworld, PID: 29338
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.helloworld/org.pytorch.helloworld.MainActivity}: com.facebook.jni.CppException: PytorchStreamReader failed locating file bytecode.pkl: file not found ()
Exception raised from valid at ../caffe2/serialize/inline_container.cc:157 (most recent call first):
(no backtrace available)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4060)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
Caused by: com.facebook.jni.CppException: PytorchStreamReader failed locating file bytecode.pkl: file not found ()
Exception raised from valid at ../caffe2/serialize/inline_container.cc:157 (most recent call first):
(no backtrace available)
at org.pytorch.LiteNativePeer.initHybrid(Native Method)
at org.pytorch.LiteNativePeer.<init>(LiteNativePeer.java:23)
at org.pytorch.LiteModuleLoader.load(LiteModuleLoader.java:29)
at org.pytorch.helloworld.MainActivity.onCreate(MainActivity.java:213)
at android.app.Activity.performCreate(Activity.java:8214)
at android.app.Activity.performCreate(Activity.java:8202)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4033)
... 11 more
and if I debug in single step. It stops at IoUtils.closeQuietly(info.fd); in handleDumpActivity function, in ActivityThread.java.