Tensorflow 之ImportError—— DLL load failed && Could not find 'cudart64_90.dll

问题出现 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系统环境变量,所以出现了上述错误)
    在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值