TensorFlow 1.3 GPU版本无法在Windows 7上运行

时间:2017-08-18 03:22:06

标签: python tensorflow windows-7 tensorflow-gpu

我是机器学习的初学者,我正在尝试使用Anaconda设置TensorFlow python环境。但是,我一直在处理“没有模块命名”的常见问题pywrap_tensorflow_internal“”

>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_
tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Anaconda3\envs\tensorflow\lib\importlib\__init__.py", line 126, in im
port_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 985, in _gcd_import
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
  File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 938, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
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 "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_
tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_
tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_
tensorflow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Anaconda3\envs\tensorflow\lib\importlib\__init__.py", line 126, in im
port_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py",
line 24, in <module>
    from tensorflow.python import *
  File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\__init_
_.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_
tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_
tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Anaconda3\envs\tensorflow\lib\importlib\__init__.py", line 126, in im
port_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 985, in _gcd_import
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
  File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 938, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
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 "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_
tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_
tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_
tensorflow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Anaconda3\envs\tensorflow\lib\importlib\__init__.py", line 126, in im
port_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

尽管存在与许多其他问题相同的错误,但没有一个解决方案似乎有效。 我在MSVCP140.DLL中安装了%PATH%并指向我,我在Python 3.5上运行它。我认为问题在于CUDA,因为当我运行TensorFlow的CPU版本时不会出现这个问题

然而,我很难弄清楚我的CUDA设置有什么问题。我安装了CUDA 8和cuDNN v5.1。 Here is what my CUDA install folder looks like. cuDNN is just the files extracted from the cuDNN zip.

此外,以下是我%PATH%的相关部分:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\cudaNN\bin\cudnn64_5.dll;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\cudaNN\include\cudnn.h;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\cudaNN\lib\x64\cudnn.lib;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\lib;
C:\Windows\System32\msvcp140.dll;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64;
C:\Windows\SysWOW64\msvcp140.dll;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;

我完全不知道我的设置有什么问题,所以非常感谢任何帮助。

1 个答案:

答案 0 :(得分:4)

如果您安装了TensorFlow 1.3的GPU版本(昨天发布),则发布的PIP包需要 cuDNN 6 。您可以从NVIDIA's website安装它。确保包含文件cudnn64_6.dll的目录包含在%PATH%环境变量中。