Could not load dynamic library 'libnvinfer.so.6'
Asked Answered
D

6

51

I am trying to normally import the TensorFlow python package, but I get the following error:

enter image description here

Here is the text from the above terminal image:

2020-02-23 19:01:06.163940: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory
2020-02-23 19:01:06.164019: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory
2020-02-23 19:01:06.164030: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] 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.
<module 'tensorflow_core._api.v2.version' from '/home/saman/miniconda3/envs/testconda/lib/python3.7/site-packages/tensorflow_core/_api/v2/version/__init__.py'
Dismissive answered 24/2, 2020 at 0:42 Comment(4)
Text, please! Copy/paste from the terminal.Depose
What OS? Have you installed all necessary libraries?Depose
stackoverflow.com/…Depose
It is Ubuntu. Are there any necessary libraries for tensorflow?Dismissive
D
53

This is a warning, not an error. You can still use TensorFlow. The shared libraries libnvinfer and libnvinfer_plugin are optional and required only if you are using nvidia's TensorRT capabilities.

To suppress this and all other warnings, set the environment variable TF_CPP_MIN_LOG_LEVEL="2".

Diencephalon answered 24/2, 2020 at 1:18 Comment(7)
Is there any way to supress this warning, as it appear on terminal every time I execute the python file?Titration
To suppress all tensorflow warnings, can set the environment variable TF_CPP_MIN_LOG_LEVEL="2".Diencephalon
I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer.so.6Inarticulate
After successfully installing as per the answer, getting the above comment everytime I import keras. What should be done?Inarticulate
what about Ubuntu 20.04? How can I find the corresponding commands for it?Dunstable
I hate when answers specify versions that are outdated within a month or two. Wondering how to solve this issue for CUDA 11.1 and 455.38Geronto
@NathanMcKaskle - it's hard for answers to keep up when the requirements change. TensorFlow's prebuilt python wheels don't seem to support CUDA 11.1. Can you use 10.1? If you can use a Docker image, that would be the best way to go because the image will have everything needed for tensorflow except the GPU drivers (which you have [version 455.38]). FWIF you do not need libnvinfer to use tensorflow.Diencephalon
T
7

I got this warning as a result of (accidental) update of libvnifer6 package. It got updated to 6.0.1-1+cuda10.2 while original installation used 6.0.1-1+cuda10.1.

After I uninstalled packages referencing cuda10.2 and re-ran

sudo apt-get install -y --no-install-recommends libnvinfer6=6.0.1-1+cuda10.1 \
    libnvinfer-dev=6.0.1-1+cuda10.1 \
    libnvinfer-plugin6=6.0.1-1+cuda10.1

this warning went away.

Tiossem answered 17/4, 2020 at 3:44 Comment(3)
You can also prevent updating of a package with apt-mark hold (manpages)Diencephalon
I am getting this error Unable to locate package libnvinfer6 can you help me with this?Frederico
@Frederico the package is provided by the developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 repository, see the snippet in the accepted answer ("Add NVIDIA package repositories")Aube
C
4

Most of these messages are warnings, not errors. They just mean that libraries to use an Nvidia GPU are not installed, but you don't have to have any Nvidia GPU to use Tensorflow so you don't need these libraries. The comment by jakub tells how to turn off the warnings:

export TF_CPP_MIN_LOG_LEVEL="2"

However, I too run Tensorflow without Nvidia stuff and there is one more message that is an error, not a warning:

2020-04-10 10:04:13.365696: E tensorflow/stream_executor/cuda/cuda_driver.cc:351] failed call to cuInit: UNKNOWN ERROR (303)

It should be irrelevant because it too refers to cuda, which is for Nvidia. It doesn't seems to be a fatal error though.

Cyperaceous answered 10/4, 2020 at 9:24 Comment(1)
If you installed tensorflow and are using a recent version, say 2.1.0, then the tensorflow package has builtin support for gpu and cpu. If you are running without a gpu, you will get this error message but it is benign. You can install the tensorflow-cpu package to exclude gpu support.Diencephalon
F
2
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb

sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt-get update

Little bit of an info from jakub's answer. This could occur if you don't install the 'machine-learning' repo. Try this if you already install CUDA successfully but still geting the error.

Then Install TensorRT. Requires that libcudnn7 is installed above.

sudo apt-get install -y --no-install-recommends libnvinfer6=6.0.1-1+cuda10.1 \
    libnvinfer-dev=6.0.1-1+cuda10.1 \
    libnvinfer-plugin6=6.0.1-1+cuda10.1
Firebug answered 23/11, 2021 at 5:54 Comment(0)
C
1

I spent like 5 hrs solving this issue. For my case, I believe it means that you have the wrong version of library. libnvinfer.so.6 is located at 'TensorRT-*/lib' and the number 6 means tensorFlow is looking for the libvinfer of TensorRT6. So if it's "could not load dynamic library libnvinfer.so.5", it means that you need TensorRT 5 to run the code.

Same as above, if it is showing Could not load dynamic library 'libcudart.so.10.0', you need the library in cuda 10.0 to run the code.

So updating your tensorrt/Cuda/Cudnn to match your tensorflow version would help. Note that your tensorrt/cuda/cudnn version should also match each other.

Christabella answered 16/12, 2020 at 0:51 Comment(0)
N
0

You can download the zip file of tensorRT 6 and then should paste the x86 linux folder file to /usr/lib/cuda make sure that the lib folder in the x86_linux folder that you have downloaded should be renamed to lib64 . After pasteing all the files in the cuda directory reboot the system . Now Cuda and TensorRT engine will run smoothly in your system.

Nutrition answered 3/11, 2020 at 18:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.