I meet the problem:
Input filename: yh_fcn_14c_include_weights.onnx
ONNX IR version: 0.0.5
Opset version: 10
Producer name: keras2onnx
Producer version: 1.5.0
Domain: onnx
Model version: 0
WARNING: ONNX model has a newer ir_version (0.0.5) than this parser was built against (0.0.3).
Parsing model
While parsing node number 1 [Conv -> "convolution_output"]:
ERROR: /data/yh/onnx-tensorrt/ModelImporter.cpp:537 In function importModel:
[5] Assertion failed: tensors.count(input_name)
please help me to fix it, thank you so much!!!!!
Hi @electronicYH did you fix the issue? I had the same problem here.
I tried to resolve the ir version warning by setting different target opset in keras2onnx but that didn't help. (I tried all the way form 1 to 10).
For the assertion failure, I checked the ModelImport.cpp. I assume it's because the code finds that one of the nodes have 0 input? Though I checked the graph of my model, don't think that's the case.
for( size_t node_idx : topological_order ) {
_current_node = node_idx;
::ONNX_NAMESPACE::NodeProto const& node = graph.node(node_idx);
std::vector<TensorOrWeights> inputs;
for( auto const& input_name : node.input() ) {
ASSERT(tensors.count(input_name), ErrorCode::kINVALID_GRAPH);
inputs.push_back(tensors.at(input_name));
}
// ...
}
On a separate note, have you run the onnx checker after exporting?
import onnx
onnx.checker.check_model(onnx_model)
The checker threw a warning for me:
Nodes in a graph must be topologically sorted, however input 'conv2d_31_Relu_0' of node:
input: "conv2d_31_Relu_0" output: "transpose_output7" name: "Transpose21" op_type: "Transpose" attribute { name: "perm" ints: 0 ints: 2 ints: 3 ints: 1 type: INTS } doc_string: "" domain: ""
is not output of any previous nodes.
However, my onnx model can run inference fine in Python API using the code below. So I assumed this shouldn't be a big issue?
import onnxruntime as rt
import numpy as np
X_test = np.ones((1,h,w,1))
sess = rt.InferenceSession("my_model.onnx")
input_name = sess.get_inputs()[0].name
label_name = sess.get_outputs()[0].name
pred_onx = sess.run([label_name], {input_name: X_test.astype(np.float32)})[0]
Any insights would be greatly appreciated!
I ran into the same problem when I ran the DeepLabV3 onnx model converted from keras on TensorRT SDK 5.1.5, how to fix the problem?
@pango99 I modify importModel code in ModelImporter.cpp, and rcompile onnx-tensorrt(https://github.com/onnx/onnx-tensorrt v5.0)

it works for me, you can have a try.
ModelImporter.cpp.zip
@pango99 I modify importModel code in ModelImporter.cpp, and rcompile onnx-tensorrt(https://github.com/onnx/onnx-tensorrt v5.0)
it works for me, you can have a try.
ModelImporter.cpp.zip
Thanks zjd1988,so can I compile onnx-tensorrt on windows platform? and can I use the compiled module with nvidia tensorrt sdk directly?
I compile onnx-tensorrt on ubuntu16.04, but it might be works well on windows, refferd from https://github.com/onnx/onnx-tensorrt/issues/60 .
you need replace the old libs (in tensorrt sdk) with newly compiled, or modify the LD_LIBRARY_PATH(add the path of onnx-tensorrt libs)
I compile onnx-tensorrt on ubuntu16.04, but it might be works well on windows, refferd from #60 .
you need replace the old libs (in tensorrt sdk) with newly compiled, or modify the LD_LIBRARY_PATH(add the path of onnx-tensorrt libs)
OK,I'll try to compile few days later
@pango99 I modify importModel code in ModelImporter.cpp, and rcompile onnx-tensorrt(https://github.com/onnx/onnx-tensorrt v5.0)
it works for me, you can have a try.
ModelImporter.cpp.zip
I used your source code and now I get different assert error:
While parsing node number 0 [Slice]:
3
ERROR: /home/ubuntu/projects/onnx-tensorrt/builtin_op_importers.cpp:1687 In function importSlice:
[6] Assertion failed: inputs.size() == 1
Any help would be appreciated.
Hi ï¼ drormeir .You can debug the onnx-tensorrt code step by step, to find out which layer assert.
After that,you can check the onnx-tensorrt suported ops from this link https://github.com/onnx/onnx-tensorrt/blob/master/operators.md
@pango99 Same issue with the parser. Ran onnx.checker.check_model(onnx_model) with no error. Were you able to build these libs on windows and resolve this error?
As @ttdd11 said, get same error while the checker did not complain.
Tried using the changes from @drormeir but somehow non of my changes actually have an effect. Also the line number of the assert does not match the one of the ModelImporter.cpp I have.
That's what my cmake looks like:
add_library(libnvonnxparser SHARED IMPORTED)
set_property(TARGET libnvonnxparser PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/onnx-tensorrt/dist/lib/libnvonnxparser.so)
add_library(libnvinfer SHARED IMPORTED)
set_property(TARGET libnvinfer PROPERTY IMPORTED_LOCATION $ENV{TRT_RELEASE}/lib/libnvinfer.so)
...
target_link_libraries(${PROJECT_NAME}
...
libnvonnxparser
libnvinfer
}
It seems that another ModelImporter.cpp is used than the one I am building but the one from the TENSORRT_ROOT folder :/ Anyone else had the same issue?
Updating to the recent 7.0.0 release of TensorRT (including 7.0.0 onnx-tensorrt) fixed the whole thing. Both the assertion and tensorrt using and old onnx-tensorrt version. At least in my case.
- [ ]
@pango99 I modify importModel code in ModelImporter.cpp, and rcompile onnx-tensorrt(https://github.com/onnx/onnx-tensorrt v5.0)
it works for me, you can have a try.
ModelImporter.cpp.zipThanks zjd1988,so can I compile onnx-tensorrt on windows platform? and can I use the compiled module with nvidia tensorrt sdk directly?
i copy your code and get error : ‘initializer_map’ was not declared in this scope
Hi @tcxia, which tensorrt version you use?
Hi @tcxia, which tensorrt version you use?
tensorRT 5.1 cuda10.1
Hi @tcxia, I tested ModelImporter.cpp.zip with tensorRT5.0, I not sure ablout tensorRT5.1. could you try this with tensorRT5.0.
I was facing same issue in tensor docker container, solution was sh /opt/tensorrt/install_opensource.sh
This issue was fixed in later TensorRT versions. If you are still having trouble with the current release version (7.1) please open another issue.
@kevinch-nv Hi, I'm unable to upgrade my TRT version as I need to use CUDA 10.2. Is there any way to solve this issue with TensorRT 6.0.1? Or is it possible to upgrade beyond 6.0.1 with CUDA 10.2?
Most helpful comment
Hi ï¼ drormeir .You can debug the onnx-tensorrt code step by step, to find out which layer assert.
After that,you can check the onnx-tensorrt suported ops from this link https://github.com/onnx/onnx-tensorrt/blob/master/operators.md