无法加载动态库“libcublas.so.10”; dlerror:libcublas.so.10:无法打开共享对象文件:没有这样的文件或目录;
Posted
技术标签:
【中文标题】无法加载动态库“libcublas.so.10”; dlerror:libcublas.so.10:无法打开共享对象文件:没有这样的文件或目录;【英文标题】:Could not load dynamic library 'libcublas.so.10'; dlerror: libcublas.so.10: cannot open shared object file: No such file or directory; 【发布时间】:2021-01-19 10:25:36 【问题描述】:当我尝试运行使用 tensorflow 的 python 脚本时,它显示以下错误...
2020-10-04 16:01:44.994797: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-10-04 16:01:46.780656: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1
2020-10-04 16:01:46.795642: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:03:00.0 name: TITAN X (Pascal) computeCapability: 6.1
coreClock: 1.531GHz coreCount: 28 deviceMemorySize: 11.91GiB deviceMemoryBandwidth: 447.48GiB/s
2020-10-04 16:01:46.795699: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-10-04 16:01:46.795808: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcublas.so.10'; dlerror: libcublas.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda/extras/CUPTI/lib64/:/usr/local/cuda-10.0/lib64
2020-10-04 16:01:46.797391: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2020-10-04 16:01:46.797707: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2020-10-04 16:01:46.799529: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2020-10-04 16:01:46.800524: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2020-10-04 16:01:46.804150: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
2020-10-04 16:01:46.804169: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
nvidia-smi 的输出
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.23.05 Driver Version: 455.23.05 CUDA Version: 11.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 TITAN X (Pascal) On | 00000000:03:00.0 Off | N/A |
| 23% 28C P8 9W / 250W | 18MiB / 12194MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1825 G /usr/lib/xorg/Xorg 9MiB |
| 0 N/A N/A 1957 G /usr/bin/gnome-shell 6MiB |
+-----------------------------------------------------------------------------+
Tensorflow 2.3.1 版, Ubuntu - 18.04
我尝试完全删除 cuda 工具包并从头开始安装,但错误仍然存在。 谁能帮我找出问题的根源??
【问题讨论】:
您的 Tensorflow 需要某个版本的 CUDA 10.x,而您已经安装了某个版本的 CUDA 11.x。您不能使用 CUDA 11.x(或任何其他版本的 CUDA)替代 CUDA 10.x 如果您的 TF 构建需要 CUDA 10.1,您必须安装 CUDA 10.1(不是最新的 CUDA)才能使用那个版本的 TF。 【参考方案1】:在 Ubuntu 20.04 上,您可以简单地安装 NVIDIAs cuda toolkit cuda
:
sudo apt-get update
sudo apt install nvidia-cuda-toolkit
还有install advices for Windows。
packge 大约 1GB,安装需要一些时间... 几分钟后,您需要 export PATH
变量才能找到它:
-
查找共享对象
sudo find / -name 'libcudart.so*'
/usr/lib/x86_64-linux-gnu/libcudart.so.10.1
/usr/lib/x86_64-linux-gnu/libcudart.so
-
将文件夹添加到
path
,以便python找到
export PATH=/usr/lib/x86_64-linux-gnu$PATH:+:$PATH
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH
-
权限
sudo chmod a+r /usr/lib/x86_64-linux-gnu/libcuda*
Helped me
【讨论】:
【参考方案2】:当您使用不兼容的 CUDA 版本运行 tensorflow 时,通常会发生这种情况。看起来这已经被问过(无法评论)。参考this问题。
【讨论】:
tnx,我在 ubuntu 20.04 中有 'libcublas.so.11' 错误,但安装 tensorflow==2.2.0 解决了我的问题。ls -l /usr/lib/x86_64-linux-gnu/libcudart.so*
显示您已安装的版本。就我而言,需要 11 个,但安装了 10 个。谢谢
而且,在pypi.org/project/tensorflow 上,您可以看到版本 10(我为 nvidia-cuda-toolkit 安装的 apt,并非所有最新版本都支持。(pip 上的最旧版本是 2.5.0rc0)
【参考方案3】:
你必须下载/更新 Cuda
如果您正在寻找 CUDA Toolkit 10.2 下载,请使用此链接: https://developer.nvidia.com/cuda-10.2-download-archive
然后激活虚拟环境并设置LD_LIBRARY_PATH,例如: Tensorflow Could not load dynamic library 'libcudart.so.10.0 on ubuntu 18.04
【讨论】:
【参考方案4】:请运行这些命令。这将解决问题
wgethttps://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get 更新
sudo apt-get -y 安装 cuda
【讨论】:
今天我更新到 Ubuntu 20.04 时似乎对我有用 - 我刚刚用 2004 替换了你所有的 1804,现在我的 Jupyter 笔记本(使用 tensorflow 和 tensorflow-gpu 2.5.0 可以看到我的 GPU。 【参考方案5】:这对我有用:
sudo apt-get install libcudart10.1
【讨论】:
以上是关于无法加载动态库“libcublas.so.10”; dlerror:libcublas.so.10:无法打开共享对象文件:没有这样的文件或目录;的主要内容,如果未能解决你的问题,请参考以下文章
Google Colaboratory ImportError: libcublas.so.10.0: cannot open shared object file: No such file or
PHP 无法加载 Imagick 库 - PHP 启动:无法加载动态库