Every example I’ve found shows using tensorflow 1.x.
I have trained an inception_v3 model (with my own classes) using tensorflow 2.3.0. I have tried keras2onnx, but get errors when try trtexe to save the engine.
Environment
TensorRT Version: 6 GPU Type: Quadro P3200 Nvidia Driver Version: 460.32.03 CUDA Version: 10.1 TensorFlow Version (if applicable): 2.3.0 Baremetal or Container (if container which image + tag): nvcr.io/nvidia/tensorrt:19.10-py3
Relevant Files
Please attach or include links to any models, data, files, or scripts necessary to reproduce your issue. (Github repo, Google Drive, Dropbox, etc.)
[01/20/2021-20:48:50] [E] [TRT] (Unnamed Layer* 39) [Concatenation]: all concat input tensors must have the same dimensions except on the concatenation axis (0), but dimensions mismatched at input 3 at index 1. Input 0 shape: [64,35,35], Input 3 shape: [32,33,33]
While parsing node number 40 [Conv]:
ERROR: builtin_op_importers.cpp:788 In function importConv:
[8] Assertion failed: (nbSpatialDims == 2 && kernel_weights.shape.nbDims == 4) || (nbSpatialDims == 3 && kernel_weights.shape.nbDims == 5)
[01/20/2021-20:48:50] [E] Failed to parse onnx file
[01/20/2021-20:48:50] [E] Parsing model failed
[01/20/2021-20:48:50] [E] Engine could not be created
&&&& FAILED TensorRT.trtexec # trtexec --onnx=./mymodel.onnx --saveEngine=my.engine
Hi @mhunsake,
Could you please try using latest trt release. And share complete verbose logs if you still face issue.
Also please validate your model with the below snippet
Could you please check input shape in the onnx file using Netron (model visualizer).
For the dims which have -1, are axis with dynamic shape. We need to use --minShape, --optShapes, --maxShapes when build the engine using trtexec.
YES it has dynamic input with name inception_v3_input and dimensions [-1, 3, 299, 299]
If I use same approach as /opt/tensorrt/samples/python/yolov3_onnx/onnx_to_tensorrt.py get_engine to convert the onnx to .trt, it has correct shape. This code is explicitly setting the input shape after parsing onnx and before building engine.
Based on /opt/tensorrt/samples/sampleSSD/ /opt/tensorrt/samples/sampleOnnxMNIST/ I have created my own sample to try the c++ code to parse onnx and create engine. It fails with same type of error
[E] [TRT] Network has dynamic or shape inputs, but no optimization profile has been defined
Could you please provide output of following command. trtexec --onnx=./best_model_loss.onnx --minShapes=inception_v3_input:1x3x299x299 --maxShapes=inception_v3_input:1x3x299x299 --optShapes=inception_v3_input:1x3x299x299 --shapes=inception_v3_input:1x3x299x299 --verbose