The android_rpc_test.py failed

Remote device: Coolpad 5267, ARMv7 Processor rev 5(v7l), installed TVM RPC, Android 6.0.1
Local machine: Intel® Xeon® CPU E5-2620 v3 @ 2.40GHz, built tvm previously

About the tvmrpc-release .apk, my targetSdkVersion is 23 and I have modified the config.mk for APP_ABI = armeabi-v7a.

I have used NDK to generate standalone toolchain for my device.
./make_standalone_toolchain.py
–arch arm --api 23 --install-dir /opt/android-toolchain-armv7

In the file android_rpc_test.py, I set arch = “armv7l” and add ‘-mfloat-abi=soft’ in my llvm target.

When the python code run f2 = remote.load_module(“cpu_lib.so”), android_rpc_test.py crashed and the TVM RPC app on my android phone also crashed.

Could you tune the model by yourself? I met this problem the generated code has some problem.However, if you auto tune the model, the issue should be resolved.

If the failure occurs when loading the module before any code execution, it might also be a build problem.

Which ndk version are you using to build your module? Can you try 16b or an older release from here?

I do not have too much experience compiling for a 32bit android target, but setting the correct arch here may also be tricky.

Check what logcat says, it should have more specific information in it.

Thank you very much!
I have tried to use 16b to rebuild the apk and the toolchain.
Finally, I solve it!
But, I have a question that why the 18b can not work?

1 Like

Good question, we have not figured this out yet either. One clue is that the latest ndk uses clang, but 16b is gcc-based.

Interestingly, the official tflite Android sample recommends an even earlier version of the ndk (14b).

I got almost the same error. The difference is that I’m target arm-v8a. This error stuck for a while. I rebuild the apk and toolchaine with 14b, but the error keeps the same. Have a closer look at the logcat, and find the following, any suggestion?

02-16 19:17:46.691 18173 18191 W System.err: Try loading tvm4j from native path. 02-16 19:17:46.695 18173 18191 W System.err: Try loading tvm4j-linux-x86_64 from native path. 02-16 19:17:46.698 18173 18191 W System.err: Attempting to load libtvm4j.so 02-16 19:17:46.702 18173 18191 W System.err: [WARN] Couldn’t find native library tvm4j. 02-16 19:17:46.702 18173 18191 W System.err: java.lang.UnsatisfiedLinkError: Couldn’t find the resource libtvm4j.so 02-16 19:17:46.702 18173 18191 W System.err: at org.apache.tvm.NativeLibraryLoader.extractResourceFileToTempDir(NativeLibraryLoader.java:127) 02-16 19:17:46.702 18173 18191 W System.err: at org.apache.tvm.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:87) 02-16 19:17:46.702 18173 18191 W System.err: at org.apache.tvm.Base.(Base.java:73) 02-16 19:17:46.702 18173 18191 W System.err: at org.apache.tvm.Function.convertFunc(Function.java:321) 02-16 19:17:46.702 18173 18191 W System.err: at org.apache.tvm.rpc.SocketChannel.(SocketChannel.java:36) 02-16 19:17:46.703 18173 18191 W System.err: at org.apache.tvm.rpc.ConnectTrackerServerProcessor.run(ConnectTrackerServerProcessor.java:165) 02-16 19:17:46.703 18173 18191 W System.err: at org.apache.tvm.tvmrpc.RPCProcessor.run(RPCProcessor.java:58) 02-16 19:17:46.703 18173 18191 W System.err: Try to load tvm4j (runtime packed version) … 02-16 19:17:46.714 18173 18191 W System.err: libtvm4j loads successfully. 02-16 19:17:46.948 18173 18191 W System.err: Load module from /data/user/0/org.apache.tvm.tvmrpc/cache/tvm4j_rpc_171386485/cpu_lib.so 02-16 19:17:46.950 18173 18191 D TVM_RUNTIME: [19:17:46] /home/zheenwang/local_new/tvm/apps/android_rpc/app/src/main/jni/…/…/…/…/…/…/3rdparty/dmlc-core/include/dmlc/logging.h:424: [19:17:46] /home/zheenwang/local_new/tvm/apps/android_rpc/app/src/main/jni/…/…/…/…/…/…/include/…/src/runtime/rpc/rpc_session.cc:1156: Check failed: rcode == kTVMModuleHandle (0 vs. 9) : 02-16 19:17:46.959 18173 18191 F art : art/runtime/thread.cc:1684] No pending exception expected: java.lang.NullPointerException: Attempt to invoke virtual method ‘org.apache.tvm.Function org.apache.tvm.Function.pushArg(java.lang.String)’ on a null object reference

Facing the same issue with ndk 16b too. Is there any solution for this? @FrozenGene @bigbigcity