The blog post is here: https://www.learnopencv.com/how-to-convert-a-model-from-pytorch-to-tensorrt-and-speed-up-inference/
To run PyTorch part:
python3 -m pip install -r requirements.txt
python3 pytorch_model.py
To run TensorRT part:
- Download and install NVIDIA CUDA 10.0 or later following by official instruction: link
- Download and extract CuDNN library for your CUDA version (login required): link
- Download and extract NVIDIA TensorRT library for your CUDA version (login required): link. The minimum required version is 6.0.1.5. Please follow the Installation Guide for your system and don't forget to install Python's part
- Add the absolute path to CUDA, TensorRT, CuDNN libs to the environment variable
PATH
orLD_LIBRARY_PATH
- Install PyCUDA
python3 trt_inference.py
Want to become an expert in AI? AI Courses by OpenCV is a great place to start.