OSError: [WinError 126] 找不到指定的模块/Could not find 'cudart64_90.dll'.

OSError: [WinError 126] 找不到指定的模块/Could not find 'cudart64_90.dll'.

原文:http://blog.csdn.net/wobeatit/article/details/79207196    

   之前一直在学深度学习的理论知识,今日心血来潮,突然想试试深度学习框架的使用,因为之前在学习卷积神经网络时,一直使用的都是python,于是此次选择深度学习框架时,我锁定了TensorFlow这一款由Google开发基于python编程的深度学习框架。

       在安装TensorFlow这一深度学习框架时,我一直是根据网上的教程去做的,初期CUDA的安装上我还是比较顺利地安装成功,因为网上的教程导向,所以我选择的搭配版本为网上教程中最常见的搭配版本:cuda 8.0+cudnn 6.0 ,然而在anaconda中安装了tensorflow-gpu模块后,之后我尝试着导入TensorFlow模块时总是会出错,现附上我导入出错的截图:

针对以上的问题简单来说,就是以下两大问题:

    1.OSError: [WinError 126] 找不到指定的模块。

    2.ImportError: Could not find 'cudart64_90.dll'. TensorFlowrequires 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

作为一个生性懒散的人,看到了上面一大串的错误,我的内心是极其崩溃的,不过问题来了总该要解决的,于是我继续了度娘、谷歌搜索之旅。无意间看到一则博客中这么一句意味深长的话:

这让我想到了可能我的TensorFlow版本号与目前安装的cuda不搭配!在anaconda中输入conda list,果断发现我的TensorFlow版本号为1.5.0,而网上cuda搭配的TensorFlow版本号为1.3.0,于是重新卸载TensorFlow-gpu包,再次重装上1.3.0的tensorflow-gpu包:

pip install –upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/gpu/tensorflow_gpu-1.3.0rc0-cp35-cp35m-win_amd64.whl

之后再次在python中输入import tensorflow as tf后,成功,现附上一段测试代码运行成功的截图:

(注:其中的截图因为博客图片大小没有设置好,可能会影响浏览,可以在图片处右键->在新标签页打开浏览~)