Converting Pytorch model to ONNX to Tensorrt

Hello,

I am trying to convert a ResNet50 based model from Pytorch to Tensorrt,
my first step is converting the model to ONNX using the torch.onnx._export() function
then converting it to TensorRT with the ONNX parser from GitHub - onnx/onnx-tensorrt: ONNX-TensorRT: TensorRT backend for ONNX

now if the Pytorch model has an x=x.view() layer the onnx converter produces Shape and Gather layers. that the Tensorrt parser cant convert.

what is the correct way to convert a network fron pytorch to Tensorrt. or is there a way to by pass this problem ?

thanks

1 Like

Hello,

have you tried convert using the default ONNX parser that’s shipped with TensorRT? Please reference the sampleOnnxMNST sample for details.

https://docs.nvidia.com/deeplearning/sdk/tensorrt-developer-guide/index.html#onnx_mnist_convert

I had the same problem (last week). The functions Shape and Gather where recently added to [url]https://github.com/onnx/onnx-tensorrt[/url].

You should build from source onnx-tensorrt (not that easy because you should also install protobuf)