我正在尝试在Windows 10上安装具有GPU支持的TensorFlow,但是导入它时出现错误(如下所示)。 CPU版本工作正常。
我有
tensorflow-gpu
这是错误:
> python
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
我的PATH环境变量(我删除了所有非Microsoft和非NVidia条目):
> echo $env:PATH.Split(';')
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp
C:\Program Files\Microsoft MPI\Bin\
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\WINDOWS\System32\OpenSSH\
C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
C:\Program Files\dotnet\
C:\Program Files (x86)\dotnet\
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.1\
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\CUPTI\lib64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include
C:\Program Files\TensorRT-5.1.2.2\lib
C:\Program Files\TensorRT-5.1.2.2\bin
C:\tools\cuda\bin
TensorRT已安装在C:\Program Files\TensorRT-5.1.2.2
中。
CUDA bin
文件夹的内容:
PS C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin> ls
Directory: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 18/04/2019 12:39 crt
-a---- 09/02/2019 06:57 202752 bin2c.exe
-a---- 09/02/2019 06:57 74850816 cublas64_10.dll
-a---- 09/02/2019 06:57 36055552 cublasLt64_10.dll
-a---- 09/02/2019 06:57 374272 cuda-memcheck.exe
-a---- 09/02/2019 06:57 4320256 cudafe++.exe
-a---- 09/02/2019 06:57 339968 cudart32_101.dll
-a---- 09/02/2019 06:57 408064 cudart64_101.dll
-a---- 18/04/2019 15:19 392566784 cudnn64_7.dll
-a---- 09/02/2019 06:57 115644416 cufft64_10.dll
-a---- 09/02/2019 06:57 225792 cufftw64_10.dll
-a---- 09/02/2019 06:57 4785664 cuinj64_101.dll
-a---- 09/02/2019 06:57 2074624 cuobjdump.exe
-a---- 09/02/2019 06:57 49030656 curand64_10.dll
-a---- 09/02/2019 06:57 171052032 cusolver64_10.dll
-a---- 09/02/2019 06:57 87930368 cusparse64_10.dll
-a---- 09/02/2019 06:57 285184 fatbinary.exe
-a---- 09/02/2019 06:57 1323008 gpu-library-advisor.exe
-a---- 09/02/2019 06:57 233472 nppc64_10.dll
-a---- 09/02/2019 06:57 10049024 nppial64_10.dll
-a---- 09/02/2019 06:57 3719680 nppicc64_10.dll
-a---- 09/02/2019 06:57 1003008 nppicom64_10.dll
-a---- 09/02/2019 06:57 7227904 nppidei64_10.dll
-a---- 09/02/2019 06:57 46016512 nppif64_10.dll
-a---- 09/02/2019 06:57 24603136 nppig64_10.dll
-a---- 09/02/2019 06:57 5848064 nppim64_10.dll
-a---- 09/02/2019 06:57 17426944 nppist64_10.dll
-a---- 09/02/2019 06:57 194560 nppisu64_10.dll
-a---- 09/02/2019 06:57 2610688 nppitc64_10.dll
-a---- 09/02/2019 06:57 8202240 npps64_10.dll
-a---- 09/02/2019 06:57 247296 nvblas64_10.dll
-a---- 09/02/2019 06:57 384000 nvcc.exe
-a---- 09/02/2019 06:57 310 nvcc.profile
-a---- 09/02/2019 06:57 22919168 nvdisasm.exe
-a---- 09/02/2019 06:57 149298688 nvgraph64_10.dll
-a---- 18/04/2019 16:46 131539456 nvinfer.dll
-a---- 18/04/2019 16:46 3663360 nvinfer_plugin.dll
-a---- 09/02/2019 06:57 5960192 nvlink.exe
-a---- 18/04/2019 16:46 4457472 nvonnxparser.dll
-a---- 18/04/2019 16:46 2447872 nvparsers.dll
-a---- 09/02/2019 06:57 4243456 nvprof.exe
-a---- 09/02/2019 06:57 221696 nvprune.exe
-a---- 09/02/2019 06:57 4580352 nvrtc-builtins64_101.dll
-a---- 09/02/2019 06:57 15659520 nvrtc64_101_0.dll
-a---- 09/02/2019 06:57 53 nvvp.bat
-a---- 09/02/2019 06:57 5838336 ptxas.exe
C:\tools
的内容:
PS C:\tools> tree /F
Folder PATH listing
Volume serial number is 6A54-3EA7
C:.
└───cuda
│ NVIDIA_SLA_cuDNN_Support.txt
│
├───bin
│ cudnn64_7.dll
│
├───include
│ cudnn.h
│
└───lib
└───x64
cudnn.lib
答案 0 :(得分:1)
问题是我安装了CUDA 10.1而不是10.0。 TensorFlow尚未与10.1兼容。
答案 1 :(得分:1)
是的,某些版本的TensorFlow不支持CUDA 10.1,在这种情况下,CUDA 10.0或更低版本将解决您的问题。
答案 2 :(得分:0)
这就是我的解决方法,如果您使用的是pip或pip3,则第一次成功的机会就较小。
conda create --name tf_gpu tensorflow-gpu
conda激活tf_gpu
停用conda