Use target=cuda build model , running a error

Traceback (most recent call last): File “script.py”, line 188, in runmodule(“t2.jpg”) File “script.py”, line 71, in runmodule module.run(data=arrary) File “/home/u260260/mntdisk/virtualenv/tvm/lib/python3.7/site-packages/tvm/contrib/graph_runtime.py”, line 206, in run self._run() File “/home/u260260/mntdisk/virtualenv/tvm/lib/python3.7/site-packages/tvm/_ffi/_ctypes/packed_func.py”, line 237, in call raise get_last_ffi_error() tvm._ffi.base.TVMError: Traceback (most recent call last): [bt] (4) /home/u260260/mntdisk/Cspace/captureframe/conver-tvm/conver1/libtvm.so(TVMFuncCall+0x61) [0x7f70e6dd93b1] [bt] (3) /home/u260260/mntdisk/Cspace/captureframe/conver-tvm/conver1/libtvm.so(tvm::runtime::GraphRuntime::Run()+0x47) [0x7f70e6e60617] [bt] (2) /home/u260260/mntdisk/Cspace/captureframe/conver-tvm/conver1/libtvm.so(+0x1943587) [0x7f70e6e60587] [bt] (1) /home/u260260/mntdisk/Cspace/captureframe/conver-tvm/conver1/libtvm.so(+0x18cdd7a) [0x7f70e6dead7a] [bt] (0) /home/u260260/mntdisk/Cspace/captureframe/conver-tvm/conver1/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x61) [0x7f70e606a561] File “/home/u260260/mntdisk/Cspace/captureframe/conver-tvm/tvm/src/runtime/library_module.cc”, line 78 TVMError:

An internal invariant was violated during the execution of TVM. Please read TVM’s error reporting guidelines. More details can be found here: https://discuss.tvm.ai/t/error-reporting/7793.

Check failed: ret == 0 (-1 vs. 0) : Assert fail: (2 == tir.tvm_struct_get(arg0, 0, 10)), Argument arg0.device_type has an unsatisfied constraint: (2 == tir.tvm_struct_get(arg0, 0, 10))

What context did you use? tvm.cpu(0) or `tvm.gpu(0)?

I used to have the same error. At that time, the error came from I set wrong context.

I fix this problem when I apply “–device cuda” option when I run “tvmc run” command to explictly specify that I want the model run on GPU.

1 Like

I don’t know if you have solved this problem. But here is my solution for those newcomers who meet the same problem

You should set your runtime array with the same device as your build target a_nd = tvm.nd.array(a_np, dev),like this. The default device is CPU, so I met the problem when I want to run the module on cuda

1 Like

Thanks for your answer, it solves my problem!