无法加载动态库“ libnvinfer.so.6”


13

我正在尝试正常导入TensorFlow python软件包,但出现以下错误:

在此处输入图片说明

这是上面终端图像中的文本:

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'

请发短信!从终端复制/粘贴。
博士

什么操作系统?您是否已安装所有必需的库?
博士


它是Ubuntu。张量流有必要的库吗?
saman jahangiri

Answers:


16

这是警告,不是错误。您仍然可以使用TensorFlow。共享库libnvinferlibnvinfer_plugin是可选的,仅在使用nvidia的TensorRT功能时才需要。

TensorFlow的安装说明列出了GPU依赖关系:

您的系统上必须安装以下NVIDIA®软件:

  • NVIDIA®GPU驱动程序— CUDA 10.1需要418.x或更高版本。
  • CUDA®工具包-TensorFlow支持CUDA 10.1(TensorFlow> = 2.1.0)
  • CUPTI随附CUDA工具包。
  • cuDNN SDK(> = 7.6)
  • (可选)TensorRT 6.0可改善延迟和吞吐量,以在某些模型上进行推理。

您可以使用以下命令(取自TensorFlow文档)在Ubuntu 18.04上安装它们:

# Add NVIDIA package repositories
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.243-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804_10.1.243-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo apt-get update
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

# Install NVIDIA driver
sudo apt-get install --no-install-recommends nvidia-driver-430
# Reboot. Check that GPUs are visible using the command: nvidia-smi

# Install development and runtime libraries (~4GB)
sudo apt-get install --no-install-recommends \
    cuda-10-1 \
    libcudnn7=7.6.4.38-1+cuda10.1  \
    libcudnn7-dev=7.6.4.38-1+cuda10.1


# 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

每当我执行python文件时,它就会出现在终端上,因此有什么办法可以抑制此警告?
inullpointer

1
要取消所有张量流警告,可以设置环境变量TF_CPP_MIN_LOG_LEVEL="2"
雅各布(Jakub)

我tensorflow / stream_executor / platform / default / dso_loader.cc:44]成功打开动态库libnvinfer.so.6
Hrushi

1
根据答案成功安装后,每次导入keras时都得到上述注释。应该做什么?
Hrushi

0

这些消息大多数是警告,而不是错误。它们只是意味着未安装使用Nvidia GPU的库,但是您不必具有任何Nvidia GPU即可使用Tensorflow,因此您不需要这些库。jakub的评论告诉您如何关闭警告:

export TF_CPP_MIN_LOG_LEVEL="2"

但是,我也没有使用Nvidia的东西运行Tensorflow,还有一条消息是错误而不是警告:

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

它应该无关紧要,因为它也涉及cuda,这是针对Nvidia的。虽然这似乎不是致命错误。


0

我由于libvnifer6软件包的(偶然)更新而收到此警告。它已更新为6.0.1-1+cuda10.2使用原始安装时6.0.1-1+cuda10.1

卸载软件包后,引用cuda10.2并重新运行

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

这个警告消失了。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.