Could not load dynamic library ‘libcudart.so.11.0‘

本文介绍了解决TensorFlow在Ubuntu 20.04上因找不到CUDA库文件导致的加载失败问题。通过查找缺失的库文件并更新环境变量,最终使TensorFlow能够正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文来自:https://github.com/tensorflow/tensorflow/issues/45930#issuecomment-770342299
我这里大致翻译以下。
I has same problem ,and solved this problem by those step.
我遇到了同样的问题,用以下步骤解决
First, find out where the “libcudart.so.11.0” is
找出libcudart.so.11.0所在
If you lost other at error stack, you can replace the “libcudart.so.11.0” by your word in below:
可以用以下命令找出

sudo find / -name 'libcudart.so.11.0'

作者以上命令比较慢,我这里用

locate libcudart.so.11.0

Output in my system.This result shows where the “libcudart.so.11.0” is in my system:
我找到了这个文件就在下面这个位置

/usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudart.so.11.0

If the result shows nothing, please make sure you have install cuda or other staff that must install in your system.
如果没有找到,请确认你是否安装了cuda
Second, add the path to environment file.
然后增加一个路径在这里 /etc/profile

sudo vim /etc/profile
append path to "LD_LIBRARY_PATH" in profile file
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.1/targets/x86_64-linux/lib

make environment file work

source /etc/profile

Last, when it all done, you can try your python code again.
Hope it help for you!

At the end
I do every thing on guide list to install tensorflow. But still occurs the same problem
my environment:
ubuntu: 20.04LTS
tensorflow: 2.4.1
python3: 3.8
pip3: 21
CUDA: 11.1
cuDNN: 8.1.0
GPU: GeForce GTX 860M
GPU Driver: 460.39

My error stack before solve this problem:

2021-01-31 15:04:10.925736: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library ‘libcudart.so.11.0’; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64
2021-01-31 15:04:10.925774: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2021-01-31 15:04:11.738577: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2021-01-31 15:04:11.771425: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-01-31 15:04:11.771969: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1770] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 860M computeCapability: 5.0
coreClock: 1.0195GHz coreCount: 5 deviceMemorySize: 1.96GiB deviceMemoryBandwidth: 74.65GiB/s
2021-01-31 15:04:11.772084: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library ‘libcudart.so.11.0’; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64
2021-01-31 15:04:11.772174: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library ‘libcublas.so.11’; dlerror: libcublas.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64
2021-01-31 15:04:11.772255: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library ‘libcublasLt.so.11’; dlerror: libcublasLt.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64
2021-01-31 15:04:11.772333: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library ‘libcufft.so.10’; dlerror: libcufft.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64
2021-01-31 15:04:11.772413: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library ‘libcurand.so.10’; dlerror: libcurand.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64
2021-01-31 15:04:11.772490: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library ‘libcusolver.so.11’; dlerror: libcusolver.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64
2021-01-31 15:04:11.772567: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library ‘libcusparse.so.11’; dlerror: libcusparse.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: :/usr/local/cuda/extras/CUPTI/lib64
2021-01-31 15:04:11.772745: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
2021-01-31 15:04:11.772763: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1803] 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…
After I fix it , the python code works fine

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值