Description
Hi all, I got an error when I tried converting the onnx model to tensorrt. The onnx model “model.onxx” is the one which I have created from a tensorflow model.
The error message is
ModelImporter.cpp:726: ERROR: ModelImporter.cpp:162 In function parseGraph:
[6] Invalid Node - StatefulPartitionedCall/sequential/flatten/Reshape
It only converts the existing onnx model “mnist.onnx” that comes along with tensorrt during its installation.
I want to know how the sample code given in the tensorrt sample directory can be used to convert the our own created onnx models to tensorrt format and make successful inference.
Below is the error log I got
[08/19/2023-06:33:09] [I] Building and running a GPU inference engine for Onnx MNIST
[08/19/2023-06:33:10] [I] [TRT] [MemUsageChange] Init CUDA: CPU +353, GPU +0, now: CPU 371, GPU 5391 (MiB)
[08/19/2023-06:33:10] [I] [TRT] ----------------------------------------------------------------
[08/19/2023-06:33:10] [I] [TRT] Input filename: …/…/data/mnist/model.onnx
[08/19/2023-06:33:10] [I] [TRT] ONNX IR version: 0.0.8
[08/19/2023-06:33:10] [I] [TRT] Opset version: 15
[08/19/2023-06:33:10] [I] [TRT] Producer name: tf2onnx
[08/19/2023-06:33:10] [I] [TRT] Producer version: 1.14.0 8f8d49
[08/19/2023-06:33:10] [I] [TRT] Domain:
[08/19/2023-06:33:10] [I] [TRT] Model version: 0
[08/19/2023-06:33:10] [I] [TRT] Doc string:
[08/19/2023-06:33:10] [I] [TRT] ----------------------------------------------------------------
[08/19/2023-06:33:10] [W] [TRT] onnx2trt_utils.cpp:364: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[08/19/2023-06:33:10] [E] [TRT] ModelImporter.cpp:720: While parsing node number 0 [Reshape → “StatefulPartitionedCall/sequential/flatten/Reshape:0”]:
[08/19/2023-06:33:10] [E] [TRT] ModelImporter.cpp:721: — Begin node —
[08/19/2023-06:33:10] [E] [TRT] ModelImporter.cpp:722: input: “flatten_input”
input: “const_fold_opt__7”
output: “StatefulPartitionedCall/sequential/flatten/Reshape:0”
name: “StatefulPartitionedCall/sequential/flatten/Reshape”
op_type: “Reshape”
[08/19/2023-06:33:10] [E] [TRT] ModelImporter.cpp:723: — End node —
[08/19/2023-06:33:10] [E] [TRT] ModelImporter.cpp:726: ERROR: ModelImporter.cpp:162 In function parseGraph:
[6] Invalid Node - StatefulPartitionedCall/sequential/flatten/Reshape
Environment
TensorRT Version: 8.0.1.6-1
GPU Type: NVIDIA Maxwell architecture with 128 NVIDIA CUDA® cores
Nvidia Driver Version: -NA-
CUDA Version: cuda10.2
CUDNN Version: - NA-
Operating System + Version: Linux ubuntu 4.9.253-tegra #2 SMP PREEMPT Tue Nov 29 18:32:41 IST 2022 aarch64 aarch64 aarch64 GNU/Linux
Python Version (if applicable): -NA-
TensorFlow Version (if applicable): -NA-
PyTorch Version (if applicable): -NA-
Baremetal or Container (if container which image + tag): -NA-
Relevant Files
This is the link from which the code is taken to convert a tensorflow mnist model into onnx model which I have named it to “model.onnx”
(https://github.com/onnx/keras-onnx/blob/master/tutorial/TensorFlow_Keras_MNIST.ipynb)
Steps To Reproduce
- From the samples directory in the installed tensorrt directory modify the file samples/sampleOnnxMNIST/sampleOnnxMNIST.cpp
The method to be modified is
samplesCommon::OnnxSampleParams initializeSampleParams()
params.onnxFileName = “mnist.onnx”;
it has to be changed to
params.onnxFileName = “model.onnx”;
-
Execute the make command and it will create a binary sample_onnx_mnist
-
Run the above binary and the error will be reproduced
Please include:
- Exact steps/commands to build your repro
- Exact steps/commands to run your repro
- Full traceback of errors encountered