Insightface: TVM device_type need to be 1 Error

Created on 4 Mar 2019  Â·  5Comments  Â·  Source: deepinsight/insightface

import numpy as np
import nnvm.compiler
import nnvm.testing
import tvm
from tvm.contrib import graph_runtime
import mxnet as mx
from mxnet import ndarray as nd

ctx = tvm.gpu()
# load the module back.
data_shape = (1,3,112,112)
loaded_json = open("./model_gpu_tvm_mobile.json").read()
loaded_lib = tvm.module.load("./model_gpu_tvm_mobile.so")
loaded_params = bytearray(open("./model_gpu_tvm_mobile.params", "rb").read())

input_data = tvm.nd.array(np.random.uniform(size=data_shape).astype("float32"))

module = graph_runtime.create(loaded_json, loaded_lib, ctx)
module.load_params(loaded_params)

# Tiny benchmark test.
import time
for i in range(100):
   t0 = time.time()
   module.run(data=input_data)
   print(time.time() - t0)
python3 mobile_model_gpu.py 
Traceback (most recent call last):
  File "mobile_model_gpu.py", line 25, in <module>
    module.run(data=input_data)
  File "/opt/github/tvm/python/tvm/contrib/graph_runtime.py", line 151, in run
    self._run()
  File "/opt/github/tvm/python/tvm/_ffi/_ctypes/function.py", line 185, in __call__
    ctypes.byref(ret_val), ctypes.byref(ret_tcode)))
  File "/opt/github/tvm/python/tvm/_ffi/base.py", line 71, in check_call
    raise TVMError(py_str(_LIB.TVMGetLastError()))
tvm._ffi.base.TVMError: [12:44:07] /opt/github/tvm/src/runtime/module_util.cc:53: Check failed: ret == 0 (-1 vs. 0) Assert fail: (dev_type == 1), device_type need to be 1

Stack trace returned 10 entries:
[bt] (0) /usr/local/lib/libtvm.so(+0x73859d) [0x7f6f0f47359d]
[bt] (1) /usr/local/lib/libtvm.so(+0xe746f3) [0x7f6f0fbaf6f3]
[bt] (2) /usr/local/lib/libtvm.so(+0xeb3767) [0x7f6f0fbee767]
[bt] (3) /usr/local/lib/libtvm.so(+0xeb1b17) [0x7f6f0fbecb17]
[bt] (4) /usr/local/lib/libtvm.so(TVMFuncCall+0x5e) [0x7f6f0fb991ee]
[bt] (5) /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(ffi_call_unix64+0x4c) [0x7f6f1499ce20]
[bt] (6) /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(ffi_call+0x2eb) [0x7f6f1499c88b]
[bt] (7) /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(_ctypes_callproc+0x49a) [0x7f6f1499701a]
[bt] (8) /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(+0x9fcb) [0x7f6f1498afcb]
[bt] (9) python3(PyObject_Call+0x47) [0x5c20e7]

Most helpful comment

@Arjun8900
if you want to compile gpu model
change
target = tvm.target.create("llvm -mcpu=haswell")
to
target = tvm.target.cuda("llvm device=0")

All 5 comments

You need to compile the gpu model.

@szad670401 @mdv3101
could you explain how to compile the gpu model? thanks!

@mdv3101 @szad670401
i think i solve it, thanks

@mdv3101 How did you solve it?

@Arjun8900
if you want to compile gpu model
change
target = tvm.target.create("llvm -mcpu=haswell")
to
target = tvm.target.cuda("llvm device=0")

Was this page helpful?
0 / 5 - 0 ratings