Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] RPCTimeEvaluator signature error #12982

Closed
Priyadrasta-2111CS10 opened this issue Oct 4, 2022 · 1 comment
Closed

[Bug] RPCTimeEvaluator signature error #12982

Priyadrasta-2111CS10 opened this issue Oct 4, 2022 · 1 comment

Comments

@Priyadrasta-2111CS10
Copy link

Expected behavior

The output should be something as follows that is shown in the user tutorial https://tvm.apache.org/docs/tutorial/cross_compilation_and_rpc.html#sphx-glr-tutorial-cross-compilation-and-rpc-py

1.389e-07 secs/op

Actual behavior

I got an error as shown below.

  File "/home/priyadrasta/rpc cross compilation.py", line 51, in <module>
    time_f = func.time_evaluator(func.entry_name, dev, number=10)
  File "/home/priyadrasta/.local/lib/python3.10/site-packages/tvm/runtime/module.py", line 335, in time_evaluator
    feval = _ffi_api.RPCTimeEvaluator(
  File "/home/priyadrasta/.local/lib/python3.10/site-packages/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
    raise get_last_ffi_error()
tvm.error.RPCError: Traceback (most recent call last):
  11: TVMFuncCall
  10: _ZN3tvm7runtime13PackedFun
  9: tvm::runtime::TypedPackedFunc<tvm::runtime::PackedFunc (tvm::runtime::Optional<tvm::runtime::Module>, std::string, int, int, int, int, int, int, int, std::string)>::AssignTypedLambda<tvm::runtime::__mk_TVM0::{lambda(tvm::runtime::Optional<tvm::runtime::Module>, std::string, int, int, int, int, int, int, int, std::string)#1}>(tvm::runtime::__mk_TVM0::{lambda(tvm::runtime::Optional<tvm::runtime::Module>, std::string, int, int, int, int, int, int, int, std::string)#1}, std::string)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs const, tvm::runtime::TVMRetValue) const
  8: tvm::runtime::RPCModuleNode::GetTimeEvaluator(std::string const&, DLDevice, int, int, int, int, int, std::string const&)
  7: tvm::runtime::RPCWrappedFunc::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const
  6: tvm::runtime::RPCClientSession::CallFunc(void*, TVMValue const*, int const*, int, std::function<void (tvm::runtime::TVMArgs)> const&)
  5: tvm::runtime::RPCEndpoint::CallFunc(void*, TVMValue const*, int const*, int, std::function<void (tvm::runtime::TVMArgs)>)
  4: tvm::runtime::RPCEndpoint::HandleUntilReturnEvent(bool, std::function<void (tvm::runtime::TVMArgs)>)
  3: tvm::runtime::RPCEndpoint::EventHandler::HandleNextEvent(bool, bool, std::function<void (tvm::runtime::TVMArgs)>)
  2: tvm::runtime::RPCEndpoint::EventHandler::HandleProcessPacket(std::function<void (tvm::runtime::TVMArgs)>)
  1: tvm::runtime::RPCEndpoint::EventHandler::HandleReturn(tvm::runtime::RPCCode, std::function<void (tvm::runtime::TVMArgs)>)
  0: _ZN3tvm7runtime6deta
  11: TVMFuncCall
  10: tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::__mk_TVM1::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::__mk_TVM1, tvm::runtime::TVMRetValue)
  9: tvm::runtime::RPCServerLoop(int)
  8: tvm::runtime::RPCEndpoint::ServerLoop()
  7: tvm::runtime::RPCEndpoint::HandleUntilReturnEvent(bool, std::function<void (tvm::runtime::TVMArgs)>)
  6: tvm::runtime::RPCEndpoint::EventHandler::HandleNextEvent(bool, bool, std::function<void (tvm::runtime::TVMArgs)>)
  5: tvm::runtime::RPCEndpoint::EventHandler::HandleProcessPacket(std::function<void (tvm::runtime::TVMArgs)>)
  4: tvm::runtime::RPCSession::AsyncCallFunc(void*, TVMValue const*, int const*, int, std::function<void (tvm::runtime::RPCCode, tvm::runtime::TVMArgs)>)
  3: tvm::runtime::LocalSession::CallFunc(void*, TVMValue const*, int const*, int, std::function<void (tvm::runtime::TVMArgs)> const&)
  2: _ZN3tvm7runtime13PackedF
  1: tvm::runtime::TypedPackedFunc<tvm::runtime::PackedFunc (tvm::runtime::Optional<tvm::runtime::Module>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int, int, int, int, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)>::AssignTypedLambda<tvm::runtime::__mk_TVM0::{lambda(tvm::runtime::Optional<tvm::runtime::Module>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int, int, int, int, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#1}>(tvm::runtime::__mk_TVM0::{lambda(tvm::runtime::Optional<tvm::runtime::Module>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int, int, int, int, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#1}, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMArgs const&) const
  0: _ZN3tvm7runtime6deta
  File "/workspace/tvm/src/runtime/rpc/rpc_endpoint.cc", line 376
RPCError: Error caught from RPC call:
[06:44:36] /home/pi/tvm/include/tvm/runtime/packed_func.h:1728: Function runtime.RPCTimeEvaluator(0: runtime.Module, 1: basic_string<char>, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, 8: int, 9: int, 10: basic_string<char>) -> runtime.PackedFunc expects 11 arguments, but 10 were provided.

Environment

I am using ubuntu 22.04 LTS as my local machine and Raspberry Pi 4 as my target remote device with an IP address : 192.168.91.173 and port: 9090

Steps to reproduce

  1. build runtime on Raspberry Pi as shown in the tutorial
  2. Set Up RPC Server on Raspberry Pi using the command : python -m tvm.exec.rpc_server --host 0.0.0.0 --port=9090
  3. save the following code in local machine with LLVM enabled as rpc cross compilation.py and run :
import numpy as np

import tvm
from tvm import te
from tvm import rpc
from tvm.contrib import utils

n = tvm.runtime.convert(1024)
A = te.placeholder((n,), name="A")
B = te.compute((n,), lambda i: A[i] + 1.0, name="B")
s = te.create_schedule(B.op)


local_demo = False

if local_demo:
   target = "llvm"
else:
   target = "llvm -mtriple=aarch64-linux-gnu"

func = tvm.build(s, [A, B], target=target, name="add_one")
# save the lib at a local temp folder
temp = utils.tempdir()

path = temp.relpath("lib.tar")

func.export_library(path)


if local_demo:
   remote = rpc.LocalSession()
else:
   # The following is my environment, change this to the IP address of your target device
   host = "192.168.91.173"  #host IP address of my Raspberry Pi
   port = 9090
   remote = rpc.connect(host, port)
   
remote.upload(path)
func = remote.load_module("lib.tar")

# create arrays on the remote device
dev = remote.cpu()
a = tvm.nd.array(np.random.uniform(size=1024).astype(A.dtype), dev)
b = tvm.nd.array(np.zeros(1024, dtype=A.dtype), dev)
# the function will run on the remote device
func(a, b)
np.testing.assert_equal(b.numpy(), a.numpy() + 1)


time_f = func.time_evaluator(func.entry_name, dev, number=10)
cost = time_f(a, b).mean
print("%g secs/op" % cost)
@masahi
Copy link
Member

masahi commented Oct 4, 2022

I remember seeing this error, it was fixed by updating and recompiling the runtime code on the device. Have you updated the runtime on the device recently?

@masahi masahi changed the title [Bug] [Bug] RPCTimeEvaluator signature error Oct 4, 2022
@masahi masahi closed this as completed Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants