Setup RPC on AWS EC2 Instance

HI,

Does anyone has experience to setup rpc server on AWS EC2 instance and connect remotely from local machine? I followed the cross compilation and RPC tutorial. I could setup RPC server on ec2 instance, but keep getting “sock.Connect(addr) Connect to xxxx:9090 failed” error while trying to connect from my Mac. I also tried to change ec2 security group settings but it didn’t work.

Are you connecting directly via RPC, or are you also using an RPC tracker?

Can you connect to the machine from your client in other ways (e.g., ssh, ping)?

I am using TVM RPC package and I think it is directly connecting?
I can connect to ec2 machine through ssh.

You can try to use ssh tunnel to map the remote port to your local Mac, it is also safer to do so

Thank you for replying. I can connect to RPC server with SSH port forwarding now. Current problem is the cross compilation:

with nnvm.compiler.build_config(opt_level=opt_level):
        graph, lib, params = nnvm.compiler.build(net, target, shape={"data": data_shape}, params=params)

    lib_fname = 'net.so'
    lib.export_library(lib_fname)
    host = 'localhost'
    port = 9090
    remote = rpc.connect(host, port)
    remote.upload(lib_fname)
    rlib = remote.load_module(lib_fname)

I set target as “llvm -target=x86_64-linux-gnu -mcpu=skylake-avx512”, but loading module returned error: tvm.ffi.base.TVMError: [22:07:45] /home/ubuntu/tvm/src/runtime/dso_module.cc:93: Check failed: lib_handle != nullptr Failed to load dynamic shared library net.so net.so: invalid ELF header.

The target device is intel skylake cpu. Is there any setting I am missing?

you should export as .o file by lib.save(“xx.o”) or do lib.export_library(“net.tar”)

It works now. We need to export lib to .tar:

lib.export_library("net.tar")