Tensorflow-gpu 1.9 无法在 Pycharm 上运行

Tensorflow-gpu 1.9 is not working on Pycharm

我无法在 pycharm 中导入 tensorflow,它引发了以下错误:

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

我检查了这个 cudart 文件并将其添加到 %PATH%

它在 CLI 上工作,python shell 完美。

我有

CUDA v9.0
cuDNN v7.0.5
tensorflow-gpu v1.9

回显%PATH%

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\CUPTI\libx64;

cudar64_90.dll 的目录:

07/27/2018  02:53 PM    <DIR>          .
07/27/2018  02:53 PM    <DIR>          ..
09/02/2017  03:45 PM           163,840 bin2c.exe
07/27/2018  02:28 PM    <DIR>          crt
05/16/2018  11:18 PM        55,161,856 cublas64_90.dll
09/02/2017  03:45 PM           347,136 cuda-memcheck.exe
09/02/2017  03:45 PM         3,930,112 cudafe++.exe
09/02/2017  03:45 PM         4,226,048 cudafe.exe
09/02/2017  03:46 PM           299,520 cudart32_90.dll
09/02/2017  03:46 PM           373,760 cudart64_90.dll
11/16/2017  07:51 PM       286,877,184 cudnn64_7.dll
09/02/2017  03:46 PM       131,197,952 cufft64_90.dll
09/02/2017  03:46 PM           199,680 cufftw64_90.dll
09/02/2017  03:46 PM         3,575,808 cuinj32_90.dll
09/02/2017  03:46 PM         4,495,360 cuinj64_90.dll
09/02/2017  03:45 PM         1,411,072 cuobjdump.exe
09/02/2017  03:46 PM        48,057,344 curand64_90.dll
09/02/2017  03:46 PM        75,222,016 cusolver64_90.dll
09/02/2017  03:46 PM        54,782,464 cusparse64_90.dll
09/02/2017  03:45 PM           246,784 fatbinary.exe
09/02/2017  03:46 PM         1,274,880 gpu-library-advisor.exe
09/02/2017  03:46 PM           205,824 nppc64_90.dll
09/02/2017  03:46 PM         9,744,384 nppial64_90.dll
09/02/2017  03:46 PM         3,953,664 nppicc64_90.dll
09/02/2017  03:46 PM         1,035,264 nppicom64_90.dll
09/02/2017  03:46 PM         7,291,392 nppidei64_90.dll
09/02/2017  03:46 PM        55,641,088 nppif64_90.dll
09/02/2017  03:46 PM        26,491,904 nppig64_90.dll
09/02/2017  03:46 PM         4,767,232 nppim64_90.dll
09/02/2017  03:46 PM        14,943,232 nppist64_90.dll
09/02/2017  03:46 PM           179,200 nppisu64_90.dll
09/02/2017  03:46 PM         2,629,120 nppitc64_90.dll
09/02/2017  03:46 PM         9,024,512 npps64_90.dll
05/16/2018  11:18 PM           241,664 nvblas64_90.dll
09/02/2017  03:45 PM           325,632 nvcc.exe
09/02/2017  03:45 PM               328 nvcc.profile
09/02/2017  03:45 PM        16,261,120 nvdisasm.exe
09/02/2017  03:46 PM        15,747,584 nvgraph64_90.dll
09/02/2017  03:45 PM         7,202,304 nvlink.exe
09/02/2017  03:45 PM         4,005,376 nvprof.exe
09/02/2017  03:45 PM           181,248 nvprune.exe
09/02/2017  03:46 PM         3,182,592 nvrtc-builtins64_90.dll
09/02/2017  03:46 PM        17,302,016 nvrtc64_90.dll
09/02/2017  03:46 PM                53 nvvp.bat
05/16/2018  11:16 PM         7,082,496 ptxas.exe

查看 tensorflow-1.9 release branch,他们似乎使用了 CUDA 9.0CUDNN 7.1.4

所以我认为你应该下载 CUDNN 7.1.4。希望问题会得到解决。

您可以通过 运行 这个由 tensorflow 的作者之一编写的方便 script 检查一切是否有效。它会准确地告诉你什么是不正常的。

编辑: 对于 CUDA 10.0,它是 CUDNN 版本 7.6.2.24-1(参见 here)。