Android_rpc_test.py does not return anything

Hello,

I am carrying out the deploy_model_on_android tutorial.

It worked well up to Register Android device to RPC Tracker.

However when I run tests/android_rpc_test.py, it does not return anything.

Apparently there is a problem with the following code execution, so I tried following code with max_retry=1.

remote = tracker.request(key, priority=0,
                             session_timeout=60)

It returned following error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/workspace/python/tvm/rpc/client.py", line 329, in request
    key, max_retry, str(last_err)))
RuntimeError: Cannot request android after 1 retry, last_error:Traceback (most recent call last):
  [bt] (4) /workspace/build/libtvm.so(TVMFuncCall+0x61) [0x7fe1e9392e51]
  [bt] (3) /workspace/build/libtvm.so(+0x9bb854) [0x7fe1e939c854]
  [bt] (2) /workspace/build/libtvm.so(+0x9ba2b4) [0x7fe1e939b2b4]
  [bt] (1) /workspace/build/libtvm.so(+0x9b6184) [0x7fe1e9397184]
  [bt] (0) /workspace/build/libtvm.so(+0x1b79e2) [0x7fe1e8b989e2]
  File "/workspace/src/runtime/rpc/rpc_socket_impl.cc", line 77
TVMError: Check failed: sock.RecvAll(&code, sizeof(code)) == sizeof(code) (0 vs. 4) :

Do you have any idea what can be the cause of the problem?
Thanks

I had this error previously, I think it occurs when you don’t use the same key for connecting the client/server so try checking that. It is the key you used in the android rpc app, in the the example you find it at tracker.request(key, priority=0, session_timeout=60).

Personally I don’t use any key (so I empty the field in the android app and put an empty string in the code). The key is useful when you have multiple devices and you want to distinguish them.

PS: you also find the devices keys in used when running python -m tvm.query_rpc_tracker in the Queue Status section (when using no key you just the output of the other columns not aligned).

Thanks!

I checked the key, but I used the same key(android).

I tried to run it without setting the key, but the result was the same.

What does python -m tvm.query_rpc_tracker return?
If you don’t find any device, this may help you

This is the return value.

Tracker address 0.0.0.0:9190

Server List
----------------------------
server-address	key
----------------------------
172.17.0.1:40150	server:android
----------------------------

Queue Status
-------------------------------
key       total  free  pending
-------------------------------
android   1      1     0
-------------------------------

hey, have you solved the problem?

@hiroki I run into the same issue. Did you solve it?

@brucechou1983 No I couldn’t resolve this issue.

I have met the same problem: python3 -m tvm.exec.query_rpc_tracker --host=0.0.0.0 --port=9190

Tracker address 0.0.0.0:9190

Server List
----------------------------
server-address	key
----------------------------
172.17.0.1:57044	server:rk3399
----------------------------

Queue Status
-------------------------------
key       total  free  pending
-------------------------------
rk3399    1      0     4
-------------------------------

Then run python3 android_rpc_test.py there is no response

This code is running in docker.

I met same issue and still not find the solution. server address is always 172.17.0.1, and is not mobile address. Both server and mobile are using same wifi.

Anyone has solution/workaround for this issue?

same problem for me. Running in docker

i just found the problem , i follow the turtorial to depoly android_rpc with docker on MacOS.

when i use python3 -m tvm.exec.query_rpc_tracker --host=0.0.0.0 --port=9190, i got server-address : 172.17.0.1 and is not my android’s ip.

when i run python3 android_rpc_test.py there is no response, and i got

" File “/workspace/python/tvm/rpc/base.py”, line 83, in recvall chunk = sock.recv(min(nbytes - nread, 1024)) ".

Then i ping my host ip and my android ip in docker continer, i CANN’T PING these two ip because "The docker (Linux) bridge network is not reachable from the macOS host."Networking features in Docker Desktop for Mac | Docker Documentation

Finally i deploy my container to Linux and it’s works. So if you use docker in MacOS, you may should do some hard work to slove the problem of network.

Hey, guys. I just solved this problem on Windows 10 + WSL2. Port redirect solves all problems.

My NAT:

  • 192.168.0.5 - device ip
  • 192.168.0.6 - windows ip

WSL addresses:

  • 172.31.48.1 - WSL address if i type “ipconfig” in Windows
  • 172.31.49.226 - WSL address if i type “ifconfig” in WSL

Look, if you don’t see your device into query_rpc_tracker list, it means that the port to which the connection is being made is closed in windows. In example this port is 9190 but i will use 9090. Oke, now open PowerShell and type
netsh interface portproxy add v4tov4 listenport=9090 listenaddress=192.168.0.6 connectport=9090 connectaddress=$($(wsl hostname -I).Trim());

You can see your connection through netsh interface portproxy show v4tov4. Output:

Address         Port        Address         Port
--------------- ----------  --------------- ----------
192.168.0.6     9090        172.31.49.226   9090

Start rpc_tracker on 0.0.0.0:9090 in WSL, connect your device and check query_rpc_tracker.

Address: 192.168.0.6
Port: 9090
Key: android

Most likely, this step was not necessary for those who use docker, because this port was forwarded when starting docker, if you followed the example. Now what everyone is here for. We see some strange address 172.31.48.1:5001.

Server List
------------------------------
server-address           key
------------------------------
     172.31.48.1:5001    server:android
------------------------------

Queue Status
-------------------------------
key       total  free  pending
-------------------------------
android   1      1     0
-------------------------------

We learn that the server and the device communicate on port 5001. This could be discovered in other ways, but accept it as a fact. Open PowerShell again netsh interface portproxy add v4tov4 listenport=5001 listenaddress=172.31.48.1 connectport=5001 connectaddress=192.168.0.5; Now the redirect looks like this

Address         Port        Address         Port
--------------- ----------  --------------- ----------
192.168.0.6     9090        172.31.49.226   9090
172.31.48.1     5001        192.168.0.5     5001

Do not forget to restart your rpc_tracker. After that, a response will be received from tracker.request. I’m sure it’s the same in docker, just forward port 5001. Somehow. I might try to do that later. I hope I can help someone in the future, good luck.

1 Like

Thank you very much, you save me a week at least

I meet the same problem where I use python3 -m tvm.exec.query_rpc_tracker --host=0.0.0.0 --port=9190 Tracker address 0.0.0.0:9190 And the result show my server-address is 172.17.0.1:5001, and it is not the real IP address of my android. I solve this problem by re-install docker without using docker desktop, and running on Ubuntu 20.04 host. After that, I got the correct server address. I guess this may be some setting in docker desktop application that lead to the transform of IP address.

I encountered the same question and follow your tutorial above, but it doesn’t work. so confused…