Android RPC failed to test

Compiled android_rpc and connect with terminal using android_rpc application and proxy using python -m tvm.exec.rpc_proxy, while running android_rpc_test script only for CPU version caused below excetion in proxy

Proxy running terminal error:

User@User-VirtualBox:~$ python -m tvm.exec.rpc_proxy
INFO:root:If you are running ROCM/Metal, fork with cause compiler internal error. Try to launch with arg --no-fork
INFO:root:RPCProxy: client port bind to 0.0.0.0:9090
INFO:root:RPCProxy: Websock port bind to 8888
INFO:root:Handler ready TCPSocketProxy:10.0.2.2:server:android
INFO:root:Invalid RPC magic from TCPSocketProxy:127.0.0.1:None
INFO:root:TCPSocketProxy:127.0.0.1:None Close socket…
INFO:root:RPCProxy:on_close TCPSocketProxy:127.0.0.1:None …
ERROR:asyncio:Exception in callback None()
handle:
Traceback (most recent call last):
File “/usr/lib/python3.6/asyncio/events.py”, line 145, in _run
self._callback(*self._args)
File “/usr/local/lib/python3.6/dist-packages/tornado/platform/asyncio.py”, line 117, in _handle_events
handler_func(fileobj, events)
File “/usr/local/lib/python3.6/dist-packages/tornado/stack_context.py”, line 276, in null_wrapper
return fn(*args, **kwargs)
File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/contrib/rpc/tornado_util.py”, line 22, in _event_handler
self._event_handler(events)
File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/contrib/rpc/tornado_util.py”, line 59, in _event_handler
if self._update_read() and (events & self._ioloop.WRITE):
File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/contrib/rpc/tornado_util.py”, line 94, in _update_read
self.on_message(msg)
File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/contrib/rpc/proxy.py”, line 140, in on_message
self.on_data(message)
File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/contrib/rpc/proxy.py”, line 97, in on_data
self._init_step(temp)
File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/contrib/rpc/proxy.py”, line 74, in _init_step
self.match_key = self.rpc_key[7:].split()[0]
IndexError: list index out of range
INFO:root:TCPSocketProxy:10.0.2.2:server:android: Error in RPC [Errno 104] Connection reset by peer
INFO:root:TCPSocketProxy:10.0.2.2:server:android Close socket…
INFO:root:RPCProxy:on_close TCPSocketProxy:10.0.2.2:server:android …

test script terminal error:

User@User-VirtualBox:~/shared-windows7/work_nnvm/work_tvm/apps/android_rpc$ python tests/android_rpc_test.py
Run CPU test …
Traceback (most recent call last):
File “tests/android_rpc_test.py”, line 75, in
test_rpc_module()
File “tests/android_rpc_test.py”, line 64, in test_rpc_module
remote.upload(path_dso2)
File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/contrib/rpc/client.py”, line 85, in upload
“tvm.contrib.rpc.server.upload”)
File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/contrib/rpc/client.py”, line 41, in get_function
return self._sess.get_function(name)
File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/_ffi/function.py”, line 103, in get_function
ctypes.byref(ret_handle)))
File “/home/User/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/_ffi/base.py”, line 66, in check_call
raise TVMError(py_str(_LIB.TVMGetLastError()))
tvm._ffi.base.TVMError: [09:23:12] /home/User/shared-windows7/work_nnvm/work_tvm/src/runtime/rpc/rpc_session.cc:808: Check failed: code == RPCCode::kReturn code=4

any additional steps need to follow excpet tutorial to connect with RPC, suspecting on recent changes this issue is induced. Any one working on this problem?

Was the Android APP + RPC Proxy working properly for you prior to the recent RPC changes?

If not, you can try checking out an earlier revision to see if that resolves your issue and we can proceed from there.

Otherwise you should check that the Android app is functioning properly e.g., if it crashes before the RPC test script fails, then that means there was a problem with the app build or loading the exported library.

I got the same problem. The app will not crash till I run the script.

Traceback (most recent call last):
File “/Users/xin/PycharmProjects/tvmtest/cl_RPC1.py”, line 213, in
remote.upload(path)
File “/Users/xin/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-macosx-10.7-x86_64.egg/tvm/contrib/rpc/client.py”, line 85, in upload
“tvm.contrib.rpc.server.upload”)
File “/Users/xin/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-macosx-10.7-x86_64.egg/tvm/contrib/rpc/client.py”, line 41, in get_function
return self._sess.get_function(name)
File “/Users/xin/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-macosx-10.7-x86_64.egg/tvm/_ffi/function.py”, line 103, in get_function
ctypes.byref(ret_handle)))
File “/Users/xin/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-macosx-10.7-x86_64.egg/tvm/_ffi/base.py”, line 66, in check_call
raise TVMError(py_str(_LIB.TVMGetLastError()))
tvm._ffi.base.TVMError: [16:04:04] src/runtime/rpc/rpc_session.cc:808: Check failed: code == RPCCode::kReturn code=4

Stack trace returned 9 entries:
[bt] (0) 0 libtvm.dylib 0x000000010b960eb0 dmlc::StackTrace() + 288
[bt] (1) 1 libtvm.dylib 0x000000010b960c4f dmlc::LogMessageFatal::~LogMessageFatal() + 47
[bt] (2) 2 libtvm.dylib 0x000000010be6f2dc std::__1::__function::__func<tvm::runtime::RPCSession::Init()::$_2, std::__1::allocatortvm::runtime::RPCSession::Init()::$_2, void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::operator()(tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&) + 204
[bt] (3) 3 libtvm.dylib 0x000000010be631bf tvm::runtime::RPCModuleNode::GetFuncHandle(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) + 223
[bt] (4) 4 libtvm.dylib 0x000000010be62f08 tvm::runtime::RPCModuleNode::GetFunction(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::shared_ptrtvm::runtime::ModuleNode const&) + 24
[bt] (5) 5 libtvm.dylib 0x000000010be3c737 tvm::runtime::Module::GetFunction(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, bool) + 55
[bt] (6) 6 libtvm.dylib 0x000000010be3c520 TVMModGetFunction + 208
[bt] (7) 7 libffi.6.dylib 0x000000010a2d8884 ffi_call_unix64 + 76
[bt] (8) 8 ??? 0x00007ffee63e0ba0 0x0 + 140732761246624

Due to openCl library inclusion android application shutdown while communicating with rpc, after remove “opencl” library reference in config.mk and re-compiled rpc application working fine with test script.

Verified with latest tvm master branch code.

Can you share the script you are using here? It is not clear what could be wrong without it.

This suggests that the problem is not due to RPC, but with some part of the build process. Where did you get the linked OpenCL library from?

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

Following my config.mk changes for android_rpc and working fine with latest tvm master branch. I can successfully can test the CPU part using test script

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

Can you see if this persists when using a different path? There may be an issue when overwriting a previously uploaded module.