简体   繁体   English

(Tensorflow-GPU) 导入 tensorflow ImportError: 找不到 'cudnn64_7.dll'

[英](Tensorflow-GPU) import tensorflow ImportError: Could not find 'cudnn64_7.dll'

After created tensorflow environment under anaconda, I installed tensorflow-gpu.在 anaconda 下创建 tensorflow 环境后,我安装了 tensorflow-gpu。 Then I was trying to import tensorflow to verify if it's correctly installed, but got this error:然后我试图导入 tensorflow 以验证它是否正确安装,但出现此错误:

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

Setup is:设置是:

NVIDIA GTX 1080
CUDA 9.0
cuDNN 6.0
tensorflow-gpu 1.5

Environment Variables are:环境变量是:

CUDA_PAT: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0
CUDA_PATH_V9_0: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0

The %Path% variables are: %Path% 变量是:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp
C:\Users\yshen\AppData\Local\cudnn-8.0-windows10-x64-v6.0\cuda\bin

it is obvious that I installed cuDNN6.0, don't why the error shows "Could not find 'cudnn64_7.dll' ".很明显我安装了cuDNN6.0,不知道为什么错误显示“找不到'cudnn64_7.dll'”。 Why it automatically searches cudnn64_7.dll instead of cudnn64_6.dll?为什么它会自动搜索 cudnn64_7.dll 而不是 cudnn64_6.dll?

Also, I got below error when I installed TensorFlow 1.8 .另外,当我安装TensorFlow 1.8时出现以下错误。 I have the Anaconda environment.我有 Anaconda 环境。

"ImportError: Could not find 'cudnn64_7.dll'" “导入错误:找不到‘cudnn64_7.dll’”

But after I installed Nvidia cuDNN v7.1.3 (April 17, 2018), for CUDA 9.0 , everything started to work.但是在我安装了Nvidia cuDNN v7.1.3 (2018 年 4 月 17 日)之后,对于CUDA 9.0 ,一切都开始工作了。 Please note that one needs to sign up as a Nvidia developer to be able to download the installation package(s).请注意,需要注册为 Nvidia 开发人员才能下载安装包。

Then, just follow the instructions in the page : cudnn-install然后,只需按照页面中的说明进行操作: cudnn-install

For Windows:对于 Windows:

3.3. 3.3. Installing cuDNN on Windows在 Windows 上安装 cuDNN

The following steps describe how to build a cuDNN dependent program.以下步骤描述了如何构建 cuDNN 依赖程序。 In the following sections:在以下部分:

-your CUDA directory path is referred to as C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0 -您的 CUDA 目录路径称为C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0

-your cuDNN directory path is referred to as <installpath> -您的 cuDNN 目录路径称为<installpath>

  1. Navigate to your <installpath> directory containing cuDNN .导航到包含cuDNN <installpath>目录。

  2. Unzip the cuDNN package.解压缩 cuDNN 包。 -cudnn-9.0-windows7-x64-v7.zip or -cudnn-9.0-windows10-x64-v7.zip -cudnn-9.0-windows7-x64-v7.zip-cudnn-9.0-windows10-x64-v7.zip

  3. Copy the following files into the CUDA Toolkit directory.将以下文件复制到 CUDA Toolkit 目录中。

    • Copy <installpath>\\cuda\\bin\\cudnn64_7.dll to C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\bin .<installpath>\\cuda\\bin\\cudnn64_7.dllC:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\bin
    • Copy <installpath>\\cuda\\ include\\cudnn.h to C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\include .<installpath>\\cuda\\ include\\cudnn.hC:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\include
    • Copy <installpath>\\cuda\\lib\\x64\\cudnn.lib to C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\lib\\x64 .<installpath>\\cuda\\lib\\x64\\cudnn.libC:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\lib\\x64
  4. Set the following environment variables to point to where cuDNN is located.设置以下环境变量以指向 cuDNN 所在的位置。 To access the value of the $(CUDA_PATH) environment variable, perform the following steps:要访问$(CUDA_PATH)环境变量的值,请执行以下步骤:

    • Open a command prompt from the Start menu.从“开始”菜单打开命令提示符。
    • Type Run and hit Enter .输入Run 并按Enter 键
    • Issue the control sysdm.cpl command.发出控制sysdm.cpl命令。
    • Select the Advanced tab at the top of the window.选择窗口顶部的高级选项卡。
    • Click Environment Variables at the bottom of the window.单击窗口底部的环境变量。
    • Ensure the following values are set: Variable Name: CUDA_PATH Variable Value: C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0确保设置了以下值: 变量名称: CUDA_PATH变量值: C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0
  5. Include cudnn.lib in your Visual Studio project.在 Visual Studio 项目中包含 cudnn.lib。

    • Open the Visual Studio project and right-click on the project name .打开 Visual Studio 项目并right-click project name
    • Click Linker > Input > Additional Dependencies .单击Linker > Input > Additional Dependencies
    • Add cudnn.lib and click OK .添加cudnn.lib并单击OK

According to you previous answer, you seem to find out prebuilt tensorflow-gpu 1.5 is not compatible with CUDA 9.0 + CudNN 6.0.根据您之前的回答,您似乎发现预构建的 tensorflow-gpu 1.5 与 CUDA 9.0 + CudNN 6.0 不兼容。 There are two possible solutions for your answer, if you want to use tensorflow-gpu 1.5:如果您想使用 tensorflow-gpu 1.5,您的答案有两种可能的解决方案:

1, upgrade your CUDA tool chain to CUDA 9.0 +Cudnn 7.0 (currently Cudnn 7.0.5 for CUDA 9.0). 1、将你的CUDA工具链升级到CUDA 9.0+Cudnn 7.0(目前CUDA 9.0为Cudnn 7.0.5)。

2, recompile the tensorflow-gpu 1.5 target for CUDA 9.0 + cudnn 6.0. 2、为CUDA 9.0 + cudnn 6.0重新编译tensorflow-gpu 1.5 target。

I suggest choosing the first option for ease.我建议选择第一个选项以方便。 But the official webpage of tensorflow 1.5 dose not deny the possibility of option 2: https://github.com/tensorflow/tensorflow/releases/tag/v1.5.0但是tensorflow 1.5的官网并不否认选项2的可能性: https : //github.com/tensorflow/tensorflow/releases/tag/v1.5.0

就我而言,我需要安装此处链接的旧 cuDNN 库

Just fould the solution:只需提出解决方案:

I checked the \\tensorflow\\python\\platform\\build_info.py and found:我检查了 \\tensorflow\\python\\platform\\build_info.py 并发现:

msvcp_dll_name = 'msvcp140.dll'
cudart_dll_name = 'cudart64_90.dll'
cuda_version_number = '9.0'
nvcuda_dll_name = 'nvcuda.dll'
cudnn_dll_name = 'cudnn64_7.dll'
cudnn_version_number = '7'

It assumes cudnn version is 7. So just need to correct it as:它假设 cudnn 版本是 7。所以只需要将其更正为:

cudnn_dll_name = 'cudnn64_6.dll'
cudnn_version_number = '6'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM