问题出现 2020/3/20
在pycharm IDE中,使用tensorflow-gpu==1.8.0进行深度学习,图像分类CNN训练,之前都还好好的,突然抽风,当模型训练好之后,再次执行计算时,便出现下面的错误:
ImportError: DLL load failed: 找不到指定的模块 Failed to load the native TensorFlow runtime
- 使用的是conda命令,从清华源下载的tensorflow-gpu=1.8.0
- nvcc -V: cuda 9.2
- cudann 7.1.4
问题解决
从网上看了好多帖子,说是重新安装tensorflow-gpu就行了。然后在anaconda虚拟环境中卸载之前的,然后从清华源重新安装时,总是下载失败。后来,参考
在anaconda中使用豆瓣源安装tensorflow
pip3 install -i https://pypi.douban.com/simple tensorflow-gpu==1.8.0
下载成功!
运行,又出现另外一个错误:
ImportError: Could not find ‘cudart64_90.dll’.
TensorFlow requires that this DLL be
installed in a directory
that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL:
https://developer.nvidia.com/cuda-toolkit
错误解析:
导入错误:找不到“cudart64_90.dll”。TensorFlow要求将此dll安装在%Path%环境变量中命名的目录中。从以下网址下载并安装CUDA 9.0:https://developer.nvidia.com/cuda-toolkit
解决方法:
cuda版本—cudnn版本----tensorflow-gpu版本之间要相互匹配。这里说的是需要有cuda 9.0,而我安装的是cuda 9.2,重新下载并配置环境变量。
- set CUDA:查看cuda的环境变量
- 查看cuda版本
然后run成功。
2020/4/6
出现的问题同上一个
ImportError: Could not find ‘cudart64_90.dll’.
TensorFlow requires that this DLL be
installed in a directory
that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL:
https://developer.nvidia.com/cuda-toolkit
由于上次已经安装了cuda9.0+tensorflow-gpu1.8.0,并正确添加了环境变量,所以不用再次重新安装了。
解决方式
run---->Edit Configurations…---->Environment–>Environment variables
Include system environment variables前面的小框一定要勾选(因为没有勾选,所以python程序中找不到cuda系统环境变量,所以出现了上述错误)