[Solved] Cannot connect to my android phone by rpc

Follow this tutorial https://docs.tvm.ai/tutorials/frontend/deploy_model_on_android.html. I build the apk successfully in docker on my macbook and install it on the phone. And then start the rpc server in docker.

python3 -m tvm.exec.rpc_tracker --host=0.0.0.0 --port=9190

However I cannot connect to the phone.

  • ip: 192.168.2.136
  • port: 9190
  • key: android
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
----------------------------
----------------------------

Queue Status
---------------------------
key   total  free  pending
---------------------------
---------------------------

The laptop can ping the phone, while phone cannot ping laptop. But I can use remote adb successfully.

If I use adb reverse tcp:9190 tcp:9190 and use

  • ip: 0.0.0.0
  • port: 9190
  • key: android

Then

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:59142	server:android
----------------------------

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

However, when I run test python3 tests/android_rpc_test.py, it has no response.

python3 tests/android_rpc_test.py
^CTraceback (most recent call last):

  File "tests/android_rpc_test.py", line 129, in <module>
    test_rpc_module()

  File "tests/android_rpc_test.py", line 57, in test_rpc_module
    session_timeout=60)

  File "/workspace/python/tvm/rpc/client.py", line 317, in request
    value = base.recvjson(self._sock)

  File "/workspace/python/tvm/rpc/base.py", line 117, in recvjson
    size = struct.unpack("<i", recvall(sock, 4))[0]

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

KeyboardInterrupt

My phone is not rooted. Do you have any idea what may be the cause of these? Thanks.

It’s my laptop’s problem. I use another computer now.

How do you fix it? I have same problem while running in docker.

My macbook cannot use because of the company’s firewall on it.