报错环境:
电脑安装了CUDA10.2+cudnn7.6.5,conda环境安装了tensorflow-gpu==2.3.0 跟cudatoolkit==10.2.89. 运行python文件报错:
2021-11-01 15:47:43.436759: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda/lib64::/opt/OpenBLAS/lib
2021-11-01 15:47:43.436804: 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.
原因分析:
查看tensorflow的官网版本介绍https://tensorflow.google.cn/install/source#gpu
tensorflow 2.3.0 对应cuda版本为10.1
GPU
版本 | Python 版本 | 编译器 | 构建工具 | cuDNN | CUDA |
---|---|---|---|---|---|
tensorflow-2.6.0 | 3.6-3.9 | GCC 7.3.1 | Bazel 3.7.2 | 8.1 | 11.2 |
tensorflow-2.5.0 | 3.6-3.9 | GCC 7.3.1 | Bazel 3.7.2 | 8.1 | 11.2 |
tensorflow-2.4.0 | 3.6-3.8 | GCC 7.3.1 | Bazel 3.1.0 | 8.0 | 11.0 |
tensorflow-2.3.0 | 3.5-3.8 | GCC 7.3.1 | Bazel 3.1.0 | 7.6 | 10.1 |
tensorflow-2.2.0 | 3.5-3.8 | GCC 7.3.1 | Bazel 2.0.0 | 7.6 | 10.1 |
解决办法:
1.直接把cuda10.2的文件拷贝成10.1
cp usr/loclal/cuda/lib64/libcudart.so.10.2 usr/loclal/cuda/lib64/libcudart.so.10.1
2.虚拟环境改装为cudatoolkit==10.1
conda install cudatoolkit=10.1
3.或者设置使用cpu
os.environ["CUDA_VISIBLE_DEVICES"]='-1'
网友评论