问题描述
>>> import tensorflow
2021-04-24 11:57:36.192957: 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-10.2/lib64:/usr/local/cuda-10.2/extras/CUPTI/lib64:
2021-04-24 11:57:36.192996: 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.
原因
没有正确配置好cuda
解决方案
1.官网查看tensorflow、python和cuDNN、CUDA的版本1
链接: link
2.利用清华源安装对应的cudnn版本、cudatoolkit版本
我的需求是这样
版本 | Python 版本 | cuDNN | CUDA |
---|---|---|---|
tensorflow-2.3.0 | 3.5-3.8 | 7.6 | 10.1 |
conda install cudatoolkit=10.1 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
conda install cudnn=7.6 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
清华源的路径写的好像有点问题,不过还是成功下载了,没有报错等信息
3.测试
>>> import tensorflow
2021-04-24 12:18:40.298589: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
运行任务也没有报错之类,用GPU详情命令2
nvidia-smi
可以看到GPU信息,并且Process那里可以看到你运行任务的PID
[1]:https://blog.youkuaiyun.com/fr555wlj/article/details/109155791
[2]:https://blog.youkuaiyun.com/sunjinshengli/article/details/108181660