Skip to content

Transformation process of a Python Pytorch GPU model into an optimized TensorRT C++ one.

Notifications You must be signed in to change notification settings

Joffreybvn/pytorch-cpp-tensorrt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTorch to C++ TensorRT

Transformation process of a Python Pytorch GPU model into an optimized C++ ONNX TensorRT one.

Process

Step 1: Train a model

Based on the Fruits 360 dataset, a model is trained with Pytorch GPU.

See the full process on:

Step 2: Convert to ONNX

The PyTorch model is evaluated. It is then converted to an ONNX model and evaluated again to ensure that its conversion does not degrade its performance.

See the full process on:

Step 3: Deploy on TensorRT

The ONNX model is finally deployed on the GPU via TensorRT, where it is evaluated again.

See the full process on:

Step 4: Transcript to C++

C++ transcription follows the same process as notebook 5 "TensorRT in Python".

Documentaion

PyTorch to TensorRT via ONNX:

Dependencies

C++ dependencies:

Python dependencies:

The following package can be installed with pip install

  • torch and torchvision
  • opencv-python
  • onnx
Other useful libraries

These very useful libraries are not used in this project, but could be interesting for data preprocessing.

  • boost, with sudo apt install libboost-all-dev - docs
  • hdf5, with sudo apt-get install libhdf5-dev - C++ API, Read example
  • HighFive 2.2.2, with Cmake - Github, C++ API
  • xtl 0.7.2, with CMake - C++ API
  • xtensor 0.23.0, with Cmake - Github, C++ API, Tutorial
  • xtensor-io dependencies, with sudo apt-get install libsndfile-dev libopenimageio-dev zlib1g-dev
  • xtensor-io 0.12.1, with Cmake - Github, C++ API

About

Transformation process of a Python Pytorch GPU model into an optimized TensorRT C++ one.

Topics

Resources

Stars

Watchers

Forks