報(bào)錯(cuò)環(huán)境:
電腦安裝了CUDA10.2+cudnn7.6.5,conda環(huán)境安裝了tensorflow-gpu==2.3.0 跟cudatoolkit==10.2.89. 運(yùn)行python文件報(bào)錯(cuò):
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的官網(wǎng)版本介紹https://tensorflow.google.cn/install/source#gpu
tensorflow 2.3.0 對(duì)應(yīng)cuda版本為10.1
GPU
版本 | Python 版本 | 編譯器 | 構(gòu)建工具 | 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.虛擬環(huán)境改裝為cudatoolkit==10.1
conda install cudatoolkit=10.1
3.或者設(shè)置使用cpu
os.environ["CUDA_VISIBLE_DEVICES"]='-1'