-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Description
I'm trying to convert the faster-rcnn.pt file to the onnx and use it with onnxruntime-gpu and tensorrt provider. When I check the converted onnx with trtexec, I get an Shape Error. One of the node has [0,16] input and that node tries to reshape it [0,-1]. Is there any way to assign the shape of the node manually ? It is because of the tools versions that I used ?
Environment
TensorRT Version: 8.6
NVIDIA GPU: Quadro RTX 4000
NVIDIA Driver Version: 530.30.02
CUDA Version: 12.1
CUDNN Version:
Operating System: Ubuntu 18.04
Python Version (if applicable): 3.9
Tensorflow Version (if applicable):
PyTorch Version (if applicable): 1.7.1
Baremetal or Container (if so, version):
Steps To Reproduce
1.Exported onnx from PyTorch weight file (faster-rcnn model)
dynamic_axes = {"input":{0:"batch_size"},
"boxes":{0:"batch_size"},
"labels":{0:"batch_size"},
"scores":{0:"batch_size"}}
torch.onnx.export(
model.to("cuda"),
dummy_input.to("cuda"),
onnx_filename,
verbose = True,
opset_version = 12,
input_names = input_names,
output_names = output_names,
dynamic_axes = dynamic_axes,
do_constant_folding=True
)
2.Applied polygraphy surgeon
polygraphy surgeon sanitize n.onnx --fold-constants --output n2.onnx
- Run trtexec on new onnx file
trtexec --onnx=n2.onnx --shapes=input:1x2x2024x2024 --verbose
ERROR: Reshape node, infinite solution for Reshaping [0,16] to [0,-1].
...
[03/22/2023-10:30:08] [E] [TRT] ModelImporter.cpp:770: input: "2881"
input: "2897"
output: "2898"
name: "Reshape_1605"
op_type: "Reshape"
[03/22/2023-10:30:08] [E] [TRT] ModelImporter.cpp:771: --- End node ---
[03/22/2023-10:30:08] [E] [TRT] ModelImporter.cpp:774: ERROR: ModelImporter.cpp:195 In function parseGraph:
[6] Invalid Node - Reshape_1605
[shapeContext.cpp::operator()::3546] Error Code 4: Shape Error (reshape wildcard -1 has infinite number of solutions or no solution. Reshaping [0,16] to [0,-1].)
[03/22/2023-10:30:08] [E] Failed to parse onnx file
[03/22/2023-10:30:08] [I] Finished parsing network model. Parse time: 0.284967
[03/22/2023-10:30:08] [E] Parsing model failed
[03/22/2023-10:30:08] [E] Failed to create engine from model or file.
[03/22/2023-10:30:08] [E] Engine set up failed
&&&& FAILED TensorRT.trtexec [TensorRT v8600] # /usr/src/tensorrt/bin/trtexec --onnx=n2.onnx --shapes=input:1x2x2024x2024 --verbose