How to install torch_tensorrt in ubuntu?

@ptrblck could you please help me here, I’m trying to install torch_tensorrt python package in ubuntu 20.04

I used the below command to install the package
pip3 install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases

when I try to import the torch_tensorrt module,
import torch_tensorrt

Error

ImportError: libnvinfer_plugin.so.8: cannot open shared object file: No such file or directory

system details

PyTorch Version (e.g., 1.0): 1.11.0
OS (e.g., Linux): LINUX
How you installed PyTorch (conda, pip, libtorch, source): conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
Python version: 3.7.13
CUDA version: 11.3.1

I have fixed this hence we can consider this as closed.

@iamexperimentingnow Hi, how could you fix this error?
I got the same.

its still not working for me, I will fix and share you the steps.

For future notice, this error is caused by the TensorRT shared objects not being in the system LD_LIBRARY_PATH

I also had those missing libraries problem with torch-tensorrt: libtorch_cuda_cu.so, libcudart.so.11.0, libnvinfer.so.8, etc…

Turns out when you
pip install torch-tensorrt==1.2.0 --find-links https://github.com/pytorch/TensorRT/releases/expanded_assets/v1.2.0
it pulls its preferred version of torch in, in my case it was 1.12.1, but it installed the old version of Cuda, namely 1.12.1+cu102, when it actually needs Cuda 11.0+.

So what i did is:
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
pip install nvidia-pyindex
pip install nvidia-tensorrt
pip install torch-tensorrt==1.2.0 --find-links https://github.com/pytorch/TensorRT/releases/expanded_assets/v1.2.0
and the errors stopped.

3 Likes