fabro66 / GAST-Net-3DPoseEstimation

A Graph Attention Spatio-temporal Convolutional Networks for 3D Human Pose Estimation in Video (GAST-Net)
MIT License
313 stars 70 forks source link

Unable to convert onnx model to tensorrt #8

Closed amek-aymen closed 3 years ago

amek-aymen commented 3 years ago

Has anyone tried converting this network to tensorrt?

I wanted to convert the pretrained network (27_frame_model.bin) to tensorrt through onnx. The conversion from pytorch to onnx seems to be OK using the following code: x = torch.randn(2,102 , 17, 2) torch.onnx.export(model, x, "GASTNet3_onnx.onnx", verbose=True, opset_version=11)

But when converting onnx to trt either with trtexec or trt python API or trt C ++ API, I get the following error:

[09/29/2020-17:44:53] [W] [TRT] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32. [09/29/2020-17:44:53] [W] [TRT] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32. [09/29/2020-17:44:53] [W] [TRT] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32. [09/29/2020-17:44:53] [W] [TRT] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32. [09/29/2020-17:44:53] [W] [TRT] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32. [09/29/2020-17:44:53] [I] [TRT] (Unnamed Layer* 8) [Matrix Multiply]: broadcasting input1 to make tensors conform, dims(input0)=[2,100,17,128][NONE] dims(input1)=[1,1,128,128][NONE]. [09/29/2020-17:44:53] [I] [TRT] (Unnamed Layer* 13) [Matrix Multiply]: broadcasting input1 to make tensors conform, dims(input0)=[2,100,17,128][NONE] dims(input1)=[1,1,128,128][NONE]. [09/29/2020-17:44:53] [E] [TRT] Cast_13: invalid weights type of Bool [09/29/2020-17:44:53] [W] [TRT] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32. [09/29/2020-17:44:53] [E] [TRT] Cast_13: invalid weights type of Bool [09/29/2020-17:44:53] [E] [TRT] Cast_13: invalid weights type of Bool [09/29/2020-17:44:53] [E] [TRT] Cast_13: invalid weights type of Bool [09/29/2020-17:44:53] [E] [TRT] Cast_13: invalid weights type of Bool [09/29/2020-17:44:53] [E] [TRT] Cast_13: invalid weights type of Bool [09/29/2020-17:44:53] [E] [TRT] Cast_13: invalid weights type of Bool While parsing node number 17 [Unsqueeze]: ERROR: onnx2trt_utils.cpp:169 In function convertAxis: [8] Assertion failed: axis >= 0 && axis < nbDims [09/29/2020-17:44:53] [E] Failed to parse onnx file [09/29/2020-17:44:53] [E] Parsing model failed [09/29/2020-17:44:53] [E] Engine creation failed [09/29/2020-17:44:53] [E] Engine set up failed &&&& FAILED TensorRT.trtexec # /TensorRT-7.1.3.4.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn8.0/TensorRT-7.1.3.4/bin/trtexec --onnx=GASTNet3_onnx.onnx --explicitBatch --saveEngine=GASTNet.engine

If I understood correctly, the problem is on value axis parameter of Unsqueeze_17 layer, however the previous unsqueeze layers don't generate the error. How to solve this problem? Thanks in advance!

torch: 1.6.0 tensorrt: 7.1.3.4 onnx: 1.7.0 opset version: 11

fabro66 commented 3 years ago

Hi~ I use the version of Torch is 1.0.1. Higher versions of Torch may be incompatible.