Windows 上的 TensorFlow:“无法打开 CUDA 库 cudnn64_5.dll”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41007279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TensorFlow on Windows: "Couldn't open CUDA library cudnn64_5.dll"
提问by Alex
Tensorflow just released windows support. I installed the gpu version and CUDA 8.0 and python 3.5. However, after I import the tensorflow I got the following error:
Tensorflow 刚刚发布了 Windows 支持。我安装了 gpu 版本和 CUDA 8.0 和 python 3.5。但是,在导入 tensorflow 后,出现以下错误:
>>> 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
Can someone help? Thanks!
有人可以帮忙吗?谢谢!
回答by mrry
TL;DR:To use cuDNN with TensorFlow, the file cudnn64_5.dll
must be in a directory that is in your %PATH%
environment variable. Note that cuDNN is a separate download from CUDA, and you must download version 5.1 of cuDNN.
TL;DR:要在 TensorFlow 中使用 cuDNN,该文件cudnn64_5.dll
必须位于%PATH%
环境变量中的目录中。请注意,cuDNN 是从 CUDA 单独下载的,您必须下载 cuDNN 5.1 版。
First of all, note that cuDNN is not distributed with the rest of the CUDA toolkit, so you will need to download it separately from the NVIDIA website. On Windows, it is distributed as a ZIP archive, so you must extract it and find the directory containing cudnn64_5.dll
. For example, if you extract it to C:\tools\cuda
, the DLL will be in C:\tools\cuda\bin\cudnn64_5.dll
. Finally, you can add it to your path by typing the following at the command prompt:
首先,请注意 cuDNN 不随 CUDA 工具包的其余部分一起分发,因此您需要从NVIDIA 网站单独下载。在 Windows 上,它作为 ZIP 存档分发,因此您必须解压缩它并找到包含cudnn64_5.dll
. 例如,如果您C:\tools\cuda
将其解压缩到,则 DLL 将位于C:\tools\cuda\bin\cudnn64_5.dll
. 最后,您可以通过在命令提示符下键入以下内容将其添加到您的路径中:
C:\> set PATH=%PATH%;C:\tools\cuda\bin
C:\> python
...
>>> import tensorflow as tf
回答by Raghav Manikandan
Tried pip3 install --upgrade tensorflow
after tensorflow-gpu
and it worked fine.
pip3 install --upgrade tensorflow
之后试了tensorflow-gpu
一下,效果很好。
I think it's an issue only when trying pip3 install --upgrade tensorflow-gpu
directly.
我认为只有pip3 install --upgrade tensorflow-gpu
直接尝试时才会出现问题。
回答by Andrey Kurapov
In addition to the answers above make sure that you've downloaded the supported version of cuDNN. Currently TensorFlow supports the older cuDNN v.5.1 while there is a newer cuDNN 6.0 available on Nvidia site. I had such errors with 6.0. When I rolled back to 5.1 everything worked.
除了上述答案外,请确保您已下载受支持的 cuDNN 版本。目前,TensorFlow 支持较旧的 cuDNN v.5.1,而 Nvidia 站点上提供了较新的 cuDNN 6.0。我在 6.0.0 中遇到过这样的错误。当我回滚到 5.1 时,一切正常。
- Check TensorFlow requirments here: https://www.tensorflow.org/install/install_windows
- Download the supported version of cuDNN from here: https://developer.nvidia.com/rdp/cudnn-download
- 在此处检查 TensorFlow 要求:https: //www.tensorflow.org/install/install_windows
- 从这里下载支持的 cuDNN 版本:https: //developer.nvidia.com/rdp/cudnn-download
回答by Dan Bricklin
I had this problem and it took me several attempts to resolve it. This answer applies to Python 64 on Windows 64 I also have VS2017 installed with Python 3.6
我遇到了这个问题,我花了好几次尝试才解决它。此答案适用于 Windows 64 上的 Python 64 我也安装了 Python 3.6 的 VS2017
From a clean Windows 64 machineInstall Visual Studio 2015 (note: NOT vs2017 -- at least not yet). The community edition is free. Make sure you install the C++ compiler. You will need this to compile future python libs.
从干净的 Windows 64 机器安装 Visual Studio 2015(注意:不是 vs2017——至少现在还没有)。社区版是免费的。确保安装了 C++ 编译器。您将需要它来编译未来的 python 库。
This will also clean up any problems with msvcp140.dll or msvcrt*.dlls. Alternatively you can install the VC Redistributable (but i recommend installing VS2015 instead as this will allow you to compile and install future python libraries).
这也将清除 msvcp140.dll 或 msvcrt*.dlls 的任何问题。或者,您可以安装 VC Redistributable(但我建议安装 VS2015,因为这将允许您编译和安装未来的 Python 库)。
Next, install VS2017 and this time also select Python and Data Learning (the scikit). This will default to installing Anaconda with Python 3.6 (built with VS2015). There are also some useful features
接下来,安装 VS2017,这次也选择 Python 和数据学习(scikit)。这将默认使用 Python 3.6(使用 VS2015 构建)安装 Anaconda。还有一些有用的功能
*Also make sure you have a compatible Nvidia card (see previous answers)
*还要确保您拥有兼容的 Nvidia 卡(请参阅之前的答案)
Then make sure you have the latest Nvidia drivers installed on your computer.
然后确保您的计算机上安装了最新的 Nvidia 驱动程序。
Then make sure you have installed the Nvidia libraries mentioned by Google and others including the Cuda bins.
然后确保你已经安装了谷歌和其他人提到的 Nvidia 库,包括 Cuda bins。
*As of tensorflow 1.2, Python 3.6 is supported so the notes on creating a Python 3.5 environment are no longer necessary
*从 tensorflow 1.2 开始,支持 Python 3.6,因此不再需要有关创建 Python 3.5 环境的说明
There are a few problems i ran into with tensorflow 1.2. I also tried tensorflow 1.31rc2 in my environment
我在使用 tensorflow 1.2 时遇到了一些问题。我也在我的环境中尝试了 tensorflow 1.31rc2
Problem #1 -- Firewalls (for those behind a firewall)
问题#1——防火墙(对于那些在防火墙后面的人)
This will prevent installations via "pip install" To fix this, add --trusted-host pypi.python.org
这将阻止通过“pip install”进行安装要解决此问题,请添加--trusted-host pypi.python.org
For example
例如
pip install tensorflow-gpu --trusted-host pypi.python.org
pip install tensorflow-gpu --trusted-host pypi.python.org
Problem #2 -- Upgrading to numpy 1.13.1
问题 #2 -- 升级到 numpy 1.13.1
Installing tensorflow will upgrade to an incompatible version of numpy 1.13.1 (at least on my windows machine). To fix this, download the wheel at http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpylook for numpy-1.13.1+mkl-cp36-cp36m-win_amd64.whl
安装 tensorflow 将升级到不兼容的 numpy 1.13.1 版本(至少在我的 Windows 机器上)。要解决此问题,请在http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy下载轮子, 查找numpy-1.13.1+mkl-cp36-cp36m-win_amd64.whl
Install this wheel beforeinstalling tensorflow. This will stop tensorflow from installing an incompatible version of the numpy 1.13.1 package
在安装 tensorflow之前安装这个轮子。这将阻止 tensorflow 安装不兼容版本的 numpy 1.13.1 包
NOTE: see how to install wheels in other posts (pip install fullpath_of_wheel)
注意:请参阅如何在其他帖子中安装轮子(pip install fullpath_of_wheel)
NOTE: if you have already installed tensorflow, make sure you force an upgrade using the --upgrade option with pip install)
注意:如果您已经安装了 tensorflow,请确保使用 --upgrade 选项和 pip install 强制升级)
Problem #3 -- Nvidia cuda packages in different locations
问题 #3——Nvidia cuda 包在不同位置
To test if you have the proper CU*.DLL packages use the "where" command (from a C:\ command prompt)
要测试您是否拥有正确的 CU*.DLL 包,请使用“where”命令(来自 C:\ 命令提示符)
where cublas64_80.dll
cublas64_80.dll在哪里
where cudnn64_5.dll
其中 cudnn64_5.dll
where cufft64_80.dll
cufft64_80.dll在哪里
where nvcuda.dll
其中 nvcuda.dll
where curand64_80.dll
其中 curand64_80.dll
where cusolver64_80.dll
cusolver64_80.dll在哪里
If your machine is like mine, you will find those dlls in multiple locations and sometimes they do not even exist. For instance, cublas64_80.dll was found in my c:\program files\Anaconda3 directory nvcuda.dll in my c:\system32\windows and so on. If you have matlab installed, it will have its own version. CNTK has its own versions also. Nvidia will put them in another directory. This is yet another problem. As mentioned by others, some of the DLLs you need are provided by Nvidia in a zip file.
如果您的机器和我的一样,您会在多个位置找到这些 dll,有时它们甚至不存在。例如,cublas64_80.dll 是在我的 c:\system32\windows 中的 c:\program files\Anaconda3 目录中找到的 nvcuda.dll 等等。如果您安装了 matlab,它将有自己的版本。CNTK 也有自己的版本。Nvidia 会将它们放在另一个目录中。这又是一个问题。正如其他人所提到的,您需要的一些 DLL 由 Nvidia 以 zip 文件的形式提供。
Instead of trying to fix up your paths, I recommend trying this first instead
与其尝试修复您的路径,我建议您先尝试一下
Collect the 6 dlls mentioned above and place them in ONE directory such as c:\tfexperiment
收集上面提到的6个dll,放在一个目录中,比如c:\tfexperiment
Then cd into c:\tfexperiment
然后 cd 进入 c:\tfexperiment
run python.exe from this location. Windows will now look for the dlls in the current path first
从这个位置运行 python.exe。Windows 现在将首先在当前路径中查找 dll
now once python loads type in
现在一旦python加载类型
import tensorflow as tf
将张量流导入为 tf
it should work for you (hopefully). This was the only way I was able to get it to work on my machine. If you get this far, you can simply add c:\tfexperiment as your first path in the path environment variable. Or you can figure out the correct path order.
它应该适合你(希望如此)。这是我能够让它在我的机器上工作的唯一方法。如果你走到这一步,你可以简单地添加 c:\tfexperiment 作为你在路径环境变量中的第一个路径。或者您可以找出正确的路径顺序。
If it STILL does not work, you can take it one step further by downloading procmon.exe from Microsoft. Run procmon.exe. Filter on the executable python.exe (sorry i dont have time to explain how to use procmon). Now go back to your python prompt and type "import tensorflow as tf" again. procmon should have many lines of information. You may want to filter on loadimage. This will tell you what dlls it is loading. Note that .pyd extensions are also DLLs. The last .dll that loaded (or failed to load) is probably the one that caused problems.
如果它仍然不起作用,您可以通过从 Microsoft 下载 procmon.exe 来更进一步。运行 procmon.exe。过滤可执行文件 python.exe(对不起,我没有时间解释如何使用 procmon)。现在回到你的python提示符并再次输入“import tensorflow as tf”。procmon 应该有很多行信息。您可能希望对 loadimage 进行过滤。这将告诉您它正在加载哪些 dll。请注意,.pyd 扩展名也是 DLL。加载(或加载失败)的最后一个 .dll 可能是导致问题的那个。
回答by Dan Bricklin
I just downloaded the cuda.dll file from this website:https://developer.nvidia.com/cudnn
我刚刚从这个网站下载了 cuda.dll 文件:https: //developer.nvidia.com/cudnn
and then moved the unzipped folder to where the rest of my anaconda libraries were.
然后将解压缩的文件夹移动到我的其余 anaconda 库所在的位置。
I use pycharm, so it was easy to see where all of the external libraries were stored within anaconda. Hope this helps!
我使用 pycharm,因此很容易看到所有外部库在 anaconda 中的存储位置。希望这可以帮助!
回答by TOBlender
For those of you that land here because of:
对于那些因为以下原因登陆这里的人:
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:119] Couldn't open CUDA library cublas64_80.dll
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_blas.cc:2294] Unable to load cuBLAS DSO.
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cudnn64_5.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 cufft64_80.dll
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_fft.cc:344] Unable to load cuFFT DSO.
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:119] Couldn't open CUDA library curand64_80.dll
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_rng.cc:338] Unable to load cuRAND DSO.
You need to add the CUDA regular path. I don't know why they didn't just put them together as one download. Very silly.
您需要添加 CUDA 常规路径。我不知道他们为什么不把它们放在一起下载。很傻。
C:\Users\user>set PATH=%PATH%;C:\tools\cuda\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
回答by michaelosthege
Also make sure that there is no additional cudnn64_5.dll
(of the wrong version) sitting in another path.
还要确保没有其他cudnn64_5.dll
(错误版本的)位于另一条路径中。
So if you put the DLL in ...\CUDA\v8.0\bin
in the past, remember that you did and do not put a newer version into ...\CuDNN\v5.1\bin
without removing the old one from the other directory.
因此,如果您将 DLL 放在...\CUDA\v8.0\bin
过去,请记住您这样做了并且不要在未...\CuDNN\v5.1\bin
从其他目录中删除旧版本的情况下将新版本放入。
回答by Dev Ross
回答by wiwengweng
As in my test, I found that TF 1.2 supports cudnn 64_5, and TF 1.3 supports cudnn 64_6. Hope this will help. :)
和我的测试一样,我发现TF 1.2支持cudnn 64_5,TF 1.3支持cudnn 64_6。希望这会有所帮助。:)
回答by Lucid Rage
You can also put the cuda64_5.dll in the C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin directory and it works fine.
也可以把cuda64_5.dll放在C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin目录下,运行正常。
You can use the folder GUI and load the .dll into the directory. Then you dont need to define the PATH every time you use Tensorflow.
您可以使用文件夹 GUI 并将 .dll 加载到目录中。那么每次使用Tensorflow时都不需要定义PATH。