問題描述:
ImportError: Could not find ‘cudnn64_7.dll’. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and this DLL is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 7 from this URL: https://developer.nvidia.com/cudnn
解決方案:
說明還是缺少東西。
注意自己所對應的版本,本人是Python3.7.4.cuda10.0.
對應官網下載自己的版本。
活該,早點老老實實用CPU版本的,嘛問題都沒有,然而我們對技術的追求就要做到極致,繼續搞環境。
繼續下載 cuDNN7,如果之前安裝的是 CUDA9,那就要下載與之對應的cuDNN版本,不然還是無法使用,我這里下載的是官方配套的7.0.5版本。
這個地址可能需要注冊登錄NVIDIA。
https://developer.nvidia.com/rdp/cudnn-download#a-collapse705-9
下面的地址是直接下載的7.0.5版本的,如果你的提示也是7版本,就用下面的地址下載。
下載完成解壓以后,把對應的文件復制到 CUDA 的安裝目錄:
a) Copy <installpath>\cuda\bin\cudnn64_7.dll to C:\Program Files
\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin.
b) Copy <installpath>\cuda\ include\cudnn.h to C:\Program Files
\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include.
c) Copy <installpath>\cuda\lib\x64\cudnn.lib to C:\Program Files
\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64
然后重新打開命令提示符,進入python交互環境,輸入 import tensorflow as tf 不報任何錯誤表示成功。
依次在python交互環境輸入以下命令:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
中途可能會打印一些日志信息,不要在意,只要不是報錯信息就行,最終會在屏幕上輸出:
Hello, TensorFlow!
表示安裝 TensorFlow GPU 版本成功。
參考文章鏈接:
https://www.imooc.com/article/26141?block_id=tuijian_wz