# Current main branch fails TensorRT unit test

**URL:** <https://discuss.tvm.apache.org/t/current-main-branch-fails-tensorrt-unit-test/9658>\
**Category:** Troubleshooting\
**Created:** [April 9, 2021, 5:52pm UTC](https://discuss.tvm.apache.org/t/current-main-branch-fails-tensorrt-unit-test/9658 "2021-04-09T17:52:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MadFunMaker](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/madfunmaker/32/2420_2.png) [@MadFunMaker](https://discuss.tvm.apache.org/u/MadFunMaker)\
**Post date:** [April 9, 2021, 5:52pm UTC](https://discuss.tvm.apache.org/t/current-main-branch-fails-tensorrt-unit-test/9658/1 "2021-04-09T17:52:45Z")

</div>

I found that the most recent TVM version fails the unit test of TensorRT. I don’t get why I have these failures given that the current version in the main branch passed the CI. I think the issue could be the version of DMLC-core or TensorRT. Does anybody have an idea as to why it happens? I tried the following command for that:

`TVM_FFI=ctypes python -m pytest -v tests/python/contrib/test_tensorrt.py`

'enabled targets: llvm; nvptx; llvm -device=arm\_cpu; cuda pytest marker: ============================= test session starts ============================== platform linux – Python 3.6.10, pytest-6.2.1, py-1.10.0, pluggy-0.13.1 – /opt/anaconda3/envs/tvm\_fleet/bin/python cachedir: .pytest\_cache rootdir: /home/byungsoj/temp\_local/tvm, configfile: pytest.ini collecting … collected 49 items

tests/python/contrib/test\_tensorrt.py::test\_tensorrt\_simple PASSED [2%] tests/python/contrib/test\_tensorrt.py::test\_tensorrt\_simple\_cpu\_io PASSED [4%] tests/python/contrib/test\_tensorrt.py::test\_tensorrt\_not\_compatible PASSED [6%] tests/python/contrib/test\_tensorrt.py::test\_tensorrt\_serialize\_graph\_executor FAILED [8%] tests/python/contrib/test\_tensorrt.py::test\_tensorrt\_serialize\_vm FAILED [10%]’

**This also seems to be related to this error I hit another time when I ran my own code to use TensorRT in TVM;**

File “/home/byungsoj/backend-aware-graph-opt/package/backend\_operator/target.py”, line 556, in measure\_cost lib = relay.build(net, target=target, params=params) File “/home/byungsoj/tvm/python/tvm/relay/build\_module.py”, line 283, in build graph\_json, runtime\_mod, params = bld\_mod.build(ir\_mod, target, target\_host, params) File “/home/byungsoj/tvm/python/tvm/relay/build\_module.py”, line 132, in build self.\_build(mod, target, target\_host) File “/home/byungsoj/tvm/python/tvm/\_ffi/\_ctypes/packed\_func.py”, line 237, in **call** raise get\_last\_ffi\_error() tvm.\_ffi.base.TVMError: Traceback (most recent call last): 11: TVMFuncCall 10: \_ZNSt17\_Function\_handlerIFvN3tvm 9: tvm::relay::backend::RelayBuildModule::GetFunction(std::\_\_cxx11::basic\_string\<char, std::char\_traits, std::allocator \> const&, tvm::runtime::ObjectPtrtvm::runtime::Object const&)::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue\*)#3}::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue\*) const 8: tvm::relay::backend::RelayBuildModule::BuildRelay(tvm::IRModule, std::unordered\_map\<std::\_\_cxx11::basic\_string\<char, std::char\_traits, std::allocator \>, tvm::runtime::NDArray, std::hash\<std::\_\_cxx11::basic\_string\<char, std::char\_traits, std::allocator \> \>, std::equal\_to\<std::\_\_cxx11::basic\_string\<char, std::char\_traits, std::allocator \> \>, std::allocator\<std::pair\<std::\_\_cxx11::basic\_string\<char, std::char\_traits, std::allocator \> const, tvm::runtime::NDArray\> \> \> const&) 7: std::\_Function\_handler\<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue\*), tvm::relay::backend::GraphRuntimeCodegenModule::GetFunction(std::\_\_cxx11::basic\_string\<char, std::char\_traits, std::allocator \> const&, tvm::runtime::ObjectPtrtvm::runtime::Object const&)::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue\*)#2}\>::\_M\_invoke(std::\_Any\_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue\*&&) 6: tvm::relay::backend::GraphRuntimeCodegen::Codegen(tvm::relay::Function) 5: tvm::relay::CompileEngineImpl::LowerExternalFunctions() 4: tvm::runtime::TypedPackedFunc\<tvm::runtime::Module (tvm::runtime::ObjectRef const&)\>::AssignTypedLambda\<tvm::runtime::Module (_)(tvm::runtime::ObjectRef const&)\>(tvm::runtime::Module (_)(tvm::runtime::ObjectRef const&), std::\_\_cxx11::basic\_string\<char, std::char\_traits, std::allocator \>)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue\*)#1}::operator()(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue\*) const 3: tvm::relay::contrib::TensorRTCompiler(tvm::runtime::ObjectRef const&) 2: tvm::relay::backend::contrib::JSONSerializer::Save(dmlc::JSONWriter\*) 1: tvm::runtime::json::JSONGraphNode::Save(dmlc::JSONWriter\*) 0: dmlc::json::Handlerdmlc::any::Write(dmlc::JSONWriter\*, dmlc::any const&) File “/home/byungsoj/tvm/3rdparty/dmlc-core/include/dmlc/json.h”, line 590 TVMError: Check failed: it != nmap.end() && it-\>first == id == false: Type St6vectorINSt7\_\_cxx1112basic\_stringIcSt11char\_traitsIcESaIcEEESaIS5\_EE has not been registered via DMLC\_JSON\_ENABLE\_ANY

---

<div class="post-metadata">

**Author:** ![comaniac](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/comaniac/32/899_2.png) [@comaniac](https://discuss.tvm.apache.org/u/comaniac)\
**Post date:** [April 9, 2021, 6:02pm UTC](https://discuss.tvm.apache.org/t/current-main-branch-fails-tensorrt-unit-test/9658/2 "2021-04-09T18:02:36Z")

</div>

@trevor-m do you have any clue?

---

<div class="post-metadata">

**Author:** ![alopez\_13](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/alopez_13/32/786_2.png) [@alopez\_13](https://discuss.tvm.apache.org/u/alopez_13)\
**Post date:** [April 9, 2021, 7:09pm UTC](https://discuss.tvm.apache.org/t/current-main-branch-fails-tensorrt-unit-test/9658/3 "2021-04-09T19:09:14Z")

</div>

I just tried:

TVM\_FFI=ctypes python3 -m pytest -v tests/python/contrib/test\_tensorrt.py

And all tests passed. That said I did `git submodule update --init --recurse` yesterday so maybe not all submodules have been updated in your setup?

Hope that helps.

---

<div class="post-metadata">

**Author:** ![MadFunMaker](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/madfunmaker/32/2420_2.png) [@MadFunMaker](https://discuss.tvm.apache.org/u/MadFunMaker)\
**Post date:** [April 9, 2021, 9:07pm UTC](https://discuss.tvm.apache.org/t/current-main-branch-fails-tensorrt-unit-test/9658/4 "2021-04-09T21:07:43Z")

</div>

Thank you for your reply! I made sure that I have updated submodules. Could you tell me which Docker image did you try with? Was it [Dockerfile.ci\_gpu](https://github.com/apache/tvm/blob/main/docker/Dockerfile.ci_gpu)? And could you share your submodule versions from “git submodule” command?

---

<div class="post-metadata">

**Author:** ![alopez\_13](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/alopez_13/32/786_2.png) [@alopez\_13](https://discuss.tvm.apache.org/u/alopez_13)\
**Post date:** [April 9, 2021, 9:53pm UTC](https://discuss.tvm.apache.org/t/current-main-branch-fails-tensorrt-unit-test/9658/5 "2021-04-09T21:53:14Z")

</div>

I am not running docker. I just cloned the project, updated the submodules, changed to the project directory and issued the command. So basically:

```
git clone --recursive https://github.com/apache/tvm tvm
cd tvm
TVM_FFI=ctypes python3 -m pytest -v tests/python/contrib/test_tensorrt.py

```

Now, if you already have your copy of the repo then pull the latest submodules: `git submodule update --init --recurse`

I do use docker for TVM related projects, but not for testing TVM itself. If you are concerned about messing your system by installing global pip libraries you can use virtual environments. That is what I do when I run outside of docker and work on TVM.

Re-reading your problem, maybe the issue is with the docker container you are using?
