Windows10 TensorFlow “Couldn't open CUDA library cudnn64_5.dll”

时间:2022-06-09 22:51:22

环境为:
Win10+TensorFlow1.0.1+GTX1060

在Windows10上配置TensorFlow with GPU,安装完CUDA和cuDNN,运行程序 时发现:

“Couldn't open CUDA library cudnn64_5.dll”

>>> import tensorflow
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cublas64_80.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:119] Couldn't open CUDA library cudnn64_5.dll
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:3459] Unable to load cuDNN DSO
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cufft64_80.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library nvcuda.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library curand64_80.dll locally

原因主要是没有找到cudnn64_5.dll,主要有两种原因:
第一种,主要是没有修改环境变量%PATH%,TensorFlow训练加载cudnn时无法找到文件。
解决方案为将cudnn文件拷贝到CUDA的默认目录(C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0)下的bin,include,lib文件夹中,再将bin,include,lib路径添加进环境变量中。
环境变量设置:
Windows10 TensorFlow “Couldn't open CUDA library cudnn64_5.dll”

第二种,就是我遇见的问题,安装时没有注意cudnn版本要求,下载安装了cudnnv6.0,安装完后自己查找文件,只有cudnn64_6.dll,没有cudnn64_5.dll。
解决方案为将cudnnV6.0替换为cudnnV5.1即可