tvm icon indicating copy to clipboard operation
tvm copied to clipboard

[Android_rpc demo error] code == RPCCode::kReturn code=4

Open badlooop opened this issue 8 years ago • 13 comments

Hi all,

I've tried to run the Android_rpc demo on Huawei Mate10 which have libOpenCL.so under /vendor/lib64.

To run the android_rpc_test.py on v0.2, I tweaked the .py file a bit.

from: from tvm.contrib import rpc, util, ndk, rpc_proxy to: from tvm.contrib import rpc, util, ndk#, rpc_proxy

The script runs well, but the App will crash after calling remote.cpu(0) or remote.gpu(0).

The key error is:

File "/home/adt/tensorflow/local/lib/python2.7/site-packages/tvm-0.2.0-py2.7-linux-x86_64.egg/tvm/_ffi/base.py", line 66, in check_call raise TVMError(py_str(_LIB.TVMGetLastError())) tvm._ffi.base.TVMError: [11:21:50] src/runtime/rpc/rpc_session.cc:741: Check failed: code == RPCCode::kReturn code=4

Does this demo work only with v0.1?

badlooop avatar Apr 09 '18 03:04 badlooop

@yzhliu Do you have time to look at this?

ZihengJiang avatar Apr 09 '18 06:04 ZihengJiang

@tqchen Does this have anything to do with recent RPC protocol change w/ tracker?

eqy avatar Apr 09 '18 19:04 eqy

@eqy can you confirm? The things should be backward compatible

tqchen avatar Apr 09 '18 19:04 tqchen

I have exact the same issue (both rpc_proxy import and Check failed: code == RPCCode::kReturn code=4), here is the related android logging:

04-09 21:19:22.524  4965  4990 W System.err: RPCProxy connected to /10.231.58.238:9090
04-09 21:19:22.534  4965  4990 W System.err: Try loading tvm4j from native path.
04-09 21:19:22.548  4965  4990 W System.err: Try loading tvm4j-linux-x86_64-gpu from native path.
04-09 21:19:22.557  4965  4990 W System.err: Try loading tvm4j-linux-x86_64-cpu from native path.
04-09 21:19:22.563  4965  4990 W System.err: [WARN] TVM native library not found in path. Copying native library from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH), or specifying by Java cmd option -Djava.library.path=[lib path].
04-09 21:19:22.568  4965  4990 W System.err: Attempting to load libtvm4j.so
04-09 21:19:22.607  4965  4990 W System.err: [WARN] Couldn't find native library tvm4j.
04-09 21:19:22.608  4965  4990 W System.err: java.lang.UnsatisfiedLinkError: Couldn't find the resource libtvm4j.so
04-09 21:19:22.609  4965  4990 W System.err: 	at ml.dmlc.tvm.NativeLibraryLoader.extractResourceFileToTempDir(NativeLibraryLoader.java:127)
04-09 21:19:22.610  4965  4990 W System.err: 	at ml.dmlc.tvm.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:87)
04-09 21:19:22.610  4965  4990 W System.err: 	at ml.dmlc.tvm.Base.<clinit>(Base.java:73)
04-09 21:19:22.611  4965  4990 W System.err: 	at ml.dmlc.tvm.Function.register(Function.java:297)
04-09 21:19:22.611  4965  4990 W System.err: 	at ml.dmlc.tvm.rpc.NativeServerLoop.serverEnv(NativeServerLoop.java:73)
04-09 21:19:22.612  4965  4990 W System.err: 	at ml.dmlc.tvm.rpc.NativeServerLoop.run(NativeServerLoop.java:44)
04-09 21:19:22.612  4965  4990 W System.err: 	at ml.dmlc.tvm.rpc.ConnectProxyServerProcessor.run(ConnectProxyServerProcessor.java:84)
04-09 21:19:22.613  4965  4990 W System.err: 	at ml.dmlc.tvm.tvmrpc.RPCProcessor.run(RPCProcessor.java:67)
04-09 21:19:22.613  4965  4990 W System.err: Try to load tvm4j (runtime packed version) ...
04-09 21:19:22.663  4965  4990 W System.err: libtvm4j loads successfully.
04-09 21:19:22.736  4965  4990 W System.err: Load module from /data/user/0/ml.dmlc.tvm.tvmrpc/cache/tvm4j_rpc_3155914576646622941/net.tar
04-09 21:19:22.780  4965  4990 E libc++abi: terminating with uncaught exception of type dmlc::Error: [21:19:22] /home/heliangliang/work/nnvm/tvm/apps/android_rpc/app/src/main/jni/jni_helper_func.h:182: Do NOT know how to handle return type code 123
04-09 21:19:22.782  4965  4990 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 4990 (Thread-2)
04-09 21:19:22.892  5429  5429 I crash_dump64: obtaining output fd from tombstoned
04-09 21:19:22.895   987   987 I /system/bin/tombstoned: received crash request for pid 4965
04-09 21:19:22.898  5429  5429 I crash_dump64: performing dump of process 4965 (target tid = 4990)
04-09 21:19:22.899  5429  5429 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-09 21:19:22.900  5429  5429 F DEBUG   : Build fingerprint: 'Xiaomi/sagit/sagit:8.0.0/OPR1.170623.027/V9.5.3.0.OCACNFA:user/release-keys'
04-09 21:19:22.900  5429  5429 F DEBUG   : Revision: '0'
04-09 21:19:22.900  5429  5429 F DEBUG   : ABI: 'arm64'
04-09 21:19:22.900  5429  5429 F DEBUG   : pid: 4965, tid: 4990, name: Thread-2  >>> ml.dmlc.tvm.tvmrpc <<<
04-09 21:19:22.900  5429  5429 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
04-09 21:19:22.904  5429  5429 F DEBUG   : Abort message: 'terminating with uncaught exception of type dmlc::Error: [21:19:22] /home/heliangliang/work/nnvm/tvm/apps/android_rpc/app/src/main/jni/jni_helper_func.h:182: Do NOT know how to handle return type code 123'
04-09 21:19:22.904  5429  5429 F DEBUG   :     x0   0000000000000000  x1   000000000000137e  x2   0000000000000006  x3   0000000000000008
04-09 21:19:22.904  5429  5429 F DEBUG   :     x4   2f0995cd690c934d  x5   2f0995cd690c934d  x6   2f0995cd690c934d  x7   7f7fffff7f7fff7f
04-09 21:19:22.904  5429  5429 F DEBUG   :     x8   0000000000000083  x9   300a96ce6a0d944e  x10  0000000000000000  x11  0000000000000001
04-09 21:19:22.904  5429  5429 F DEBUG   :     x12  ffffffffffffffff  x13  0000000000000001  x14  002dee57f34613c6  x15  00009e81989451a3
04-09 21:19:22.904  5429  5429 F DEBUG   :     x16  0000007b560212f8  x17  0000007b55fc2d40  x18  0000000000000020  x19  0000000000001365
04-09 21:19:22.904  5429  5429 F DEBUG   :     x20  000000000000137e  x21  0000007b3bdbcd38  x22  00000000ffffff80  x23  00000000ffffffc8
04-09 21:19:22.904  5429  5429 F DEBUG   :     x24  0000007b3bdbce00  x25  0000007b3bdbccd0  x26  0000007b3bdbcd10  x27  0000000000000001
04-09 21:19:22.904  5429  5429 F DEBUG   :     x28  0000000000000004  x29  0000007b3bdbcc40  x30  0000007b55f76e54
04-09 21:19:22.904  5429  5429 F DEBUG   :     sp   0000007b3bdbcc00  pc   0000007b55fc2d48  pstate 0000000060000000
04-09 21:19:22.908  5429  5429 F DEBUG   : 
04-09 21:19:22.908  5429  5429 F DEBUG   : backtrace:
04-09 21:19:22.908  5429  5429 F DEBUG   :     #00 pc 0000000000069d48  /system/lib64/libc.so (tgkill+8)
04-09 21:19:22.908  5429  5429 F DEBUG   :     #01 pc 000000000001de50  /system/lib64/libc.so (abort+88)
04-09 21:19:22.908  5429  5429 F DEBUG   :     #02 pc 0000000000107e78  /data/app/ml.dmlc.tvm.tvmrpc-cc-vy001lGNJn6RDa74VPw==/lib/arm64/libtvm4j_runtime_packed.so
04-09 21:19:22.909  5429  5429 F DEBUG   :     #03 pc 0000000000107fd8  /data/app/ml.dmlc.tvm.tvmrpc-cc-vy001lGNJn6RDa74VPw==/lib/arm64/libtvm4j_runtime_packed.so
04-09 21:19:22.909  5429  5429 F DEBUG   :     #04 pc 0000000000104b74  /data/app/ml.dmlc.tvm.tvmrpc-cc-vy001lGNJn6RDa74VPw==/lib/arm64/libtvm4j_runtime_packed.so
04-09 21:19:22.909  5429  5429 F DEBUG   :     #05 pc 000000000010423c  /data/app/ml.dmlc.tvm.tvmrpc-cc-vy001lGNJn6RDa74VPw==/lib/arm64/libtvm4j_runtime_packed.so (__cxa_throw+128)
04-09 21:19:22.909  5429  5429 F DEBUG   :     #06 pc 0000000000074218  /data/app/ml.dmlc.tvm.tvmrpc-cc-vy001lGNJn6RDa74VPw==/lib/arm64/libtvm4j_runtime_packed.so (_ZN4dmlc15LogMessageFatalD2Ev+104)
04-09 21:19:22.909  5429  5429 F DEBUG   :     #07 pc 000000000008b4c0  /data/app/ml.dmlc.tvm.tvmrpc-cc-vy001lGNJn6RDa74VPw==/lib/arm64/libtvm4j_runtime_packed.so (_Z17tvmRetValueToJavaP7_JNIEnv8TVMValuei+224)
04-09 21:19:22.909  5429  5429 F DEBUG   :     #08 pc 000000000008bf80  /data/app/ml.dmlc.tvm.tvmrpc-cc-vy001lGNJn6RDa74VPw==/lib/arm64/libtvm4j_runtime_packed.so (Java_ml_dmlc_tvm_LibInfo_tvmFuncCall+448)
04-09 21:19:22.909  5429  5429 F DEBUG   :     #09 pc 000000000000e9c0  /data/app/ml.dmlc.tvm.tvmrpc-cc-vy001lGNJn6RDa74VPw==/oat/arm64/base.odex (offset 0xe000)

llhe avatar Apr 10 '18 01:04 llhe

By the way, the ./tests/android_rpc_test.py runs well without crash, and mali_imagenet_bench.py crashed with this error:

Abort message: 'terminating with uncaught exception of type dmlc::Error: [21:19:22] /home/heliangliang/work/nnvm/tvm/apps/android_rpc/app/src/main/jni/jni_helper_func.h:182: Do NOT know how to handle return type code 123'

The command used:

python mali_imagenet_bench.py --target-host 'llvm -target=arm64-linux-android' --host 10.231.58.238 --port 9090 --model mobilenet

llhe avatar Apr 10 '18 01:04 llhe

move discussions to https://discuss.tvmlang.org/

tqchen avatar May 19 '18 16:05 tqchen

Meet the same issue. Any new progress? By the way, I can not access https://discuss.tvmlang.org/

nolanliou avatar Jun 05 '18 13:06 nolanliou

i have same issue on Xiaomi Max:

08-08 10:33:56.190 3409-3409/? I/art: Late-enabling -Xcheck:jni 08-08 10:33:56.225 3409-3409/? D/TidaProvider: TidaProvider() 08-08 10:33:56.333 3409-3409/ml.dmlc.tvm.android.demo W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 08-08 10:33:56.471 3409-3409/ml.dmlc.tvm.android.demo V/BoostFramework: mAcquireFunc method = public int com.qualcomm.qti.Performance.perfLockAcquire(int,int[]) 08-08 10:33:56.472 3409-3409/ml.dmlc.tvm.android.demo V/BoostFramework: mReleaseFunc method = public int com.qualcomm.qti.Performance.perfLockRelease() 08-08 10:33:56.472 3409-3409/ml.dmlc.tvm.android.demo V/BoostFramework: mAcquireTouchFunc method = public int com.qualcomm.qti.Performance.perfLockAcquireTouch(android.view.MotionEvent,android.util.DisplayMetrics,int,int[]) 08-08 10:33:56.472 3409-3409/ml.dmlc.tvm.android.demo V/BoostFramework: mIOPStart method = public int com.qualcomm.qti.Performance.perfIOPrefetchStart(int,java.lang.String) 08-08 10:33:56.472 3409-3409/ml.dmlc.tvm.android.demo V/BoostFramework: mIOPStop method = public int com.qualcomm.qti.Performance.perfIOPrefetchStop() 08-08 10:33:56.474 3409-3409/ml.dmlc.tvm.android.demo V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@24f9991 08-08 10:33:56.475 3409-3409/ml.dmlc.tvm.android.demo V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@3d4c0f6 08-08 10:33:56.496 3409-3424/ml.dmlc.tvm.android.demo D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true 08-08 10:33:56.528 3409-3425/ml.dmlc.tvm.android.demo I/MainActivity: Reading synset name from: imagenet.shortnames.list 08-08 10:33:56.539 3409-3409/ml.dmlc.tvm.android.demo D/ActivityThreadInjector: clearCachedDrawables. 08-08 10:33:56.581 3409-3424/ml.dmlc.tvm.android.demo I/Adreno: QUALCOMM build : b73542d, I2a1af65146 Build Date : 03/29/16 OpenGL ES Shader Compiler Version: XE031.06.00.02 Local Branch : mybranch18960460 Remote Branch : quic/LA.BR.1.3.4_rb1.8 Remote Branch : NONE Reconstruct Branch : NOTHING 08-08 10:33:56.604 3409-3424/ml.dmlc.tvm.android.demo I/OpenGLRenderer: Initialized EGL, version 1.4 08-08 10:33:56.662 3409-3425/ml.dmlc.tvm.android.demo I/MainActivity: Reading json graph from: deploy_graph.json 08-08 10:33:56.665 3409-3425/ml.dmlc.tvm.android.demo I/MainActivity: Uploading compiled function to cache folder 08-08 10:33:57.873 3409-3425/ml.dmlc.tvm.android.demo W/System.err: Try loading tvm4j from native path. 08-08 10:33:57.876 3409-3425/ml.dmlc.tvm.android.demo W/System.err: Try loading tvm4j-linux-x86_64 from native path. 08-08 10:33:57.878 3409-3425/ml.dmlc.tvm.android.demo W/System.err: [WARN] TVM native library not found in path. Copying native library from the archive. Consider installing the library somewhere in the path (for Windows: PATH, for Linux: LD_LIBRARY_PATH), or specifying by Java cmd option -Djava.library.path=[lib path]. 08-08 10:33:57.882 3409-3425/ml.dmlc.tvm.android.demo W/System.err: Attempting to load libtvm4j.so 08-08 10:33:57.906 3409-3425/ml.dmlc.tvm.android.demo W/System.err: [WARN] Couldn't find native library tvm4j. 08-08 10:33:57.907 3409-3425/ml.dmlc.tvm.android.demo W/System.err: java.lang.UnsatisfiedLinkError: Couldn't find the resource libtvm4j.so 08-08 10:33:57.909 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at ml.dmlc.tvm.NativeLibraryLoader.extractResourceFileToTempDir(NativeLibraryLoader.java:127) 08-08 10:33:57.909 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at ml.dmlc.tvm.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:87) 08-08 10:33:57.909 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at ml.dmlc.tvm.Base.(Base.java:73) 08-08 10:33:57.909 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at ml.dmlc.tvm.Function.listGlobalFuncNames(Function.java:52) 08-08 10:33:57.909 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at ml.dmlc.tvm.Function.getFunction(Function.java:38) 08-08 10:33:57.909 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at ml.dmlc.tvm.Module.getApi(Module.java:41) 08-08 10:33:57.909 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at ml.dmlc.tvm.Module.load(Module.java:139) 08-08 10:33:57.909 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at ml.dmlc.tvm.Module.load(Module.java:145) 08-08 10:33:57.910 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at ml.dmlc.tvm.android.demo.MainActivity$LoadModleAsyncTask.doInBackground(MainActivity.java:184) 08-08 10:33:57.910 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at ml.dmlc.tvm.android.demo.MainActivity$LoadModleAsyncTask.doInBackground(MainActivity.java:124) 08-08 10:33:57.910 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295) 08-08 10:33:57.910 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 08-08 10:33:57.910 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 08-08 10:33:57.910 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 08-08 10:33:57.910 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 08-08 10:33:57.910 3409-3425/ml.dmlc.tvm.android.demo W/System.err: at java.lang.Thread.run(Thread.java:818) 08-08 10:33:57.910 3409-3425/ml.dmlc.tvm.android.demo W/System.err: Try to load tvm4j (runtime packed version) ... 08-08 10:33:57.923 3409-3425/ml.dmlc.tvm.android.demo W/System.err: libtvm4j loads successfully

13301338176 avatar Aug 08 '18 02:08 13301338176

For reference, discuss are moved to https://discuss.tvm.ai/

tqchen avatar Aug 08 '18 17:08 tqchen

Same issue, crashed when doing this: remote.upload(path_dso_cpu)

wincle avatar Nov 07 '18 07:11 wincle

Same issue, this problem has been plagued for many days.

RoyZhang1 avatar Apr 03 '19 06:04 RoyZhang1

FYI, I fixed this issue after changing the ndk version to v16

ZihengJiang avatar Apr 29 '19 19:04 ZihengJiang

changing to v16 didnt work for me. did anyone solved it? thanks

vadimAnyVision avatar Sep 10 '19 11:09 vadimAnyVision