ImportError: libnvinfer.so.4: cannot open shared object file: No such file or directory

I am running ubuntu 14.04 and have installed tensorrt.
When I open up my python terminal and try to import tensorrt, I get the following error:

import tensorrt
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python2.7/dist-packages/tensorrt/init.py”, line 77, in
from tensorrt import infer, parsers, utils, lite, plugins
File “/usr/local/lib/python2.7/dist-packages/tensorrt/infer/init.py”, line 54, in
from ._infer_enums import *
File “/usr/local/lib/python2.7/dist-packages/tensorrt/infer/_infer_enums.py”, line 54, in
from tensorrt.infer import _nv_infer_bindings as nvinfer
ImportError: libnvinfer.so.4: cannot open shared object file: No such file or directory

I see that libnvinfer.so.4 is present in the tar file which I downloaded from the website.

Note: I also tried to run tensorrt on Ubuntu 16.04 and I get the same libnvinfer error when I am installing it.

Try setting the correct LD_LIBRARY_PATH to tensorrt/lib, something like this:

export LD_LIBRARY_PATH=“/usr/local/cuda-9.0/lib64:/opt/TensorRT-4.0.0.3/lib”

1 Like

libnvinfer.so.4: cannot open shared object file: No such file or directory

*I have tried setting the correct LD_LIBRARY_PATH to tensorrt/lib, something like this:

export LD_LIBRARY_PATH=“./TensorRT-4.0.1.6/lib”

*I find that libnvinfer.so.4 is on the directory “./TensorRT-4.0.1.6/targets/x86_64-linux-gnu/lib”

*I also try export LD_LIBRARY_PATH=“./TensorRT-4.0.1.6/targets/x86_64-linux-gnu/lib”

2 Likes

Maybe try setting the path from from the root folder and not use ./ at the start.

I usually set paths in .bashrc file, that works for, give that a try

$sudo gedit ~/.bashrc
## Add the export command at the bottom, save and close
$source ~/.bashrc

mg5610 have you tried to use it via docker image?. I had the same issues and decided to work with it via docker

1 Like

Hi Sanchezvr7,
Where is the docker image available?

Abramjos I am using the container image from nvidia: nvcr.io/nvidia/tensorflow:18.07-py3 which already includes TensorRT 4.0.1. Here is the link with its description https://docs.nvidia.com/deeplearning/dgx/tensorflow-release-notes/rel_18.07.html

Also you can find other container images from nvidia here in their website Nvidia GPU Cloud: NVIDIA NGC

Here is the command I used to pull the image:

docker pull nvcr.io/nvidia/tensorflow:18.07-py3
1 Like

sudo cp TensorRT-5.XXX/targets/x86_64-linux-gnu/lib/lib* /usr/lib/

6 Likes

@tangzhem I forgot to copy the lib file to PATH, now it worked.
Thanks

I am still facing the same issue and I can see the lib file in Path folder as well.
PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin:/opt/bin:/opt/TensorRT-7.0.0.11/targets/x86_64-linux-gnu/lib/:/opt/TensorRT-7.0.0.11/targets/x86_64-linux-gnu/bin/

And I can see the file there in the folder.
Can someone please help?