Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the right libnvinfer version for Cuda

I am building a Docker image, for deep learning:

cuda:11.2.0-cudnn8-devel-ubuntu20.04
PYTHON_VERSION=3.7.9

For this task I need 3 dependencies to install, but I can't find the right version. The error I get, when building the Docker image:

E: Version '8.1.1.33-1+cuda11.2' for 'libnvinfer8' was not found E: Version '8.1.1.33-1+cuda11.2' for 'libnvinfer-dev' was not found E: Version '8.1.1.33-1+cuda11.2' for 'libnvinfer-plugin8' was not found

I was experimenting with other versions as well, but I had no success, so the question is: where/how can I find the right versions which works with cuda 11.2 and ubuntu 20.04. Is there a rule of thumb?

like image 710
TkrA Avatar asked Dec 07 '25 07:12

TkrA


1 Answers

To check which version of TensorRT your tensorflow installation expects:

>>> import tensorflow
>>> tensorflow.__version__
'2.8.0'
>>> from tensorflow.python.compiler.tensorrt import trt_convert as trt
>>> trt.trt_utils._pywrap_py_utils.get_linked_tensorrt_version()
(7, 2, 2)
>>> trt.trt_utils._pywrap_py_utils.get_loaded_tensorrt_version()
2022-03-24 08:59:15.415733: W tensorflow/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: /usr/local/nvidia/lib:/usr/local/nvidia/lib64

The last command shows that indeed libnvinfer.so is missing on your system (you can also check this fact using ldconfig -p | grep libnv).

To install it (adapted from Tensorflow's gpu.Dockerfile), take the TensorRT version in your output from above, double check it's available for your CUDA version on the nvidia repository, and install:

export LIBNVINFER=7.2.2 LIBNVINFER_MAJOR_VERSION=7 CUDA_VERSION=11.0
apt-get install -y libnvinfer${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}-1+${CUDA_VERSION} libnvinfer-plugin${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}-1+${CUDA_VERSION}

The last Python command above should now start working. If you get a similar error again, double check that the so file locations (check with ldconfig -p | grep libnv) are included in LD_LIBRARY_PATH.

Also double check your CUDA version. In my case, I was running the docker.io/nvidia/cuda:11.5.1-cudnn8-runtime-ubuntu20.04 image, which already contains the math libraries and specifically libnvrtc.so.11.2 (so for a newer CUDA version than TensorRT supports on the nvidia repository). This becomes evident after running the apt-get command above, which gave this output:

The following packages have unmet dependencies:
 libnvinfer7 : Depends: cuda-nvrtc-11-0 but it is not going to be installed
like image 90
ddelange Avatar answered Dec 08 '25 21:12

ddelange