Auto tuning Failed on android phone

When running "tune_relay_arm.py " on a android phone, it alwasys display ” 0.00/ 0.00 GFLOPS”, and the error message is:
DEBUG:autotvm:No: 1 GFLOPS: 0.00/0.00 result: MeasureResult(costs=(RuntimeError(‘Traceback (most recent call last):\n [bt] (4) ~/tvm/build/libtvm.so(TVMFuncCall+0x61) [0x7f30a3d90401]\n [bt] (3) ~/tvm/build/libtvm.so(+0xf39534) [0x7f30a3dd3534]\n [bt] (2) ~/tvm/build/libtvm.so(+0xf38ac9) [0x7f30a3dd2ac9]\n [bt] (1) ~/tvm/build/libtvm.so(+0xf29032) [0x7f30a3dc3032]\n [bt] (0) ~/tvm/build/libtvm.so(+0x743bf2) [0x7f30a35ddbf2]\n File “~/tvm/src/runtime/rpc/rpc_session.cc”, line 856\nTVMError: Check failed: code == RPCCode: :kReturn: code=4’,),), error_no=4, all_cost=2.582179069519043, timestamp=1554709595.4641685) [(‘tile_ic’, [2, 128]), (‘tile_oc’, [8, 64]), (‘tile_ow’, [1, 7]), (‘tile_oh’, 1)],direct,None,151
DEBUG:autotvm:No: 2 GFLOPS: 0.00/0.00 result: MeasureResult(costs=(RuntimeError(‘Traceback (most recent call last):\n [bt] (4) ~/tvm/build/libtvm.so(TVMFuncCall+0x61) [0x7f30a3d90401]\n [bt] (3) ~/tvm/build/libtvm.so(+0xf39534) [0x7f30a3dd3534]\n [bt] (2) ~/tvm/build/libtvm.so(+0xf38ac9) [0x7f30a3dd2ac9]\n [bt] (1) ~/tvm/build/libtvm.so(+0xf29032) [0x7f30a3dc3032]\n [bt] (0) ~/tvm/build/libtvm.so(+0x743bf2) [0x7f30a35ddbf2]\n File “~/tvm/src/runtime/rpc/rpc_session.cc”, line 856\nTVMError: Check failed: code == RPCCode: :kReturn: code=4’,),), error_no=4, all_cost=5.320638656616211, timestamp=1554709598.111878) [(‘tile_ic’, [8, 32]), (‘tile_oc’, [8, 64]), (‘tile_ow’, [7, 1]), (‘tile_oh’, 2)],direct,None,239
DEBUG:autotvm:No: 3 GFLOPS: 0.00/0.00 result: MeasureResult(costs=(RuntimeError(‘Traceback (most recent call last):\n [bt] (4) ~/tvm/build/libtvm.so(TVMFuncCall+0x61) [0x7f30a3d90401]\n [bt] (3) ~/tvm/build/libtvm.so(+0xf39534) [0x7f30a3dd3534]\n [bt] (2) ~/tvm/build/libtvm.so(+0xf38ac9) [0x7f30a3dd2ac9]\n [bt] (1) ~/tvm/build/libtvm.so(+0xf29032) [0x7f30a3dc3032]\n [bt] (0) ~/tvm/build/libtvm.so(+0x743bf2) [0x7f30a35ddbf2]\n File “~/tvm/src/runtime/rpc/rpc_session.cc”, line 856\nTVMError: Check failed: code == RPCCode: :kReturn: code=4’,),), error_no=4, all_cost=17.815212726593018, timestamp=1554709605.945705) [(‘tile_ic’, [2, 128]), (‘tile_oc’, [1, 512]), (‘tile_ow’, [7, 1]), (‘tile_oh’, 1)],direct,None,88

What’s the problem?

By the way:
Local System: Ubuntu 16.04
Remote Phone: MI 5X
Android System: 7.1.2
tracker_host = ‘192.168.42.86’
tracker_port = 9090
device_key = ‘android’
target = ‘llvm -target=arm64-linux-android’
The RPC test is ok.

Can you share your tuning script? It is likely that there is a issue with the build configuration somewhere.

The script is https://github.com/dmlc/tvm/blob/master/tutorials/autotvm/tune_relay_arm.py, I just changed tracker_host and tracker_port to my phone adress.
The modified places are in red rect regions:

If I set use_android = True, the error message is:

You should set use_android in this case; the error may be introduced because there was some build function refactoring recently. Can you see if this change fixes your problem?

1 Like

Yes,the tunning progress works now, but compiling failed. it display KeyError: ‘tile_co’ error. and then I checked the android resnet-18.log file, it could not find ‘tile_co’ keywords.

What opt_level are you using throughout the script? It could be that tuning was done without the layout transformation pass enabled, so if the pass is enabled during compilation there could be a configuration mismatch.

1 Like

Thanks, it works now. the opt_level is 3, when I set the target = ‘llvm -device=arm_cpu -target=arm64-linux-android’, it’ all right. Thanks you!

1 Like

by the way, the inference time is running on single thread or multi-thread, any options to set the thread numbers?

By default it should be multithreaded. You use config_threadpool to set CPU affinity https://github.com/dmlc/tvm/blob/cffb4fba03ea582417e2630bd163bca773756af6/src/runtime/thread_pool.cc#L362, or use the TVM_NUM_THREADS environment variable to change the number of cores.