Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load dynamic library 'libnvinfer.so.7'

I know that this question has been asked a lot, but none of the suggestions seem to work, probably since my setup is somewhat different:

Ubuntu          22.04
python          3.10.8
tensorflow      2.11.0
cudatoolkit     11.2.2
cudnn           8.1.0.77
nvidia-tensorrt 8.4.3.1
nvidia-pyindex  1.0.9

Having created a conda environment 'tf', in the directory home/dan/anaconda3/envs/tf/lib/python3.10/site-packages/tensorrt I have

libnvinfer_builder_resource.so.8.4.3
libnvinfer_plugin.so.8
libnvinfer.so.8
libnvonnxparser.so.8
libnvparsers.so.8
tensorrt.so

When running python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))" I get

tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7';
dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory;
LD_LIBRARY_PATH: :/home/dan/anaconda3/envs/tf/lib

tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7';
dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory;
LD_LIBRARY_PATH: :/home/dan/anaconda3/envs/tf/lib

tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.

[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

I'm guessing I should downgrade nvidia-tensorrt, but nothing I've tried seems to work, any advice would be much appreciated.

like image 212
Daniel von Eschwege Avatar asked Sep 06 '25 23:09

Daniel von Eschwege


1 Answers

For me the setting a symbolic link from libnvinfer version 7 to 8 worked:

# the following path will be different for you - depending on your install method
$ cd env/lib/python3.10/site-packages/tensorrt

# create symbolic links
$ ln -s libnvinfer_plugin.so.8 libnvinfer_plugin.so.7
$ ln -s libnvinfer.so.8 libnvinfer.so.7

# add tensorrt to library path
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/env/lib/python3.10/site-packages/tensorrt/
like image 117
thalhamm Avatar answered Sep 11 '25 03:09

thalhamm