Windows上的Tensorflow(DLL加载失败和ModuleNotFoundError)

时间:2017-08-17 12:25:41

标签: python python-3.x windows-10 tensorflow-gpu

我正在尝试在Windows 10上安装tensorflow(GPU)。我按照https://www.tensorflow.org/install/install_windows上的说明操作。

在安装过程中我没有发现任何问题但是当我尝试导入tensorflow时出现此错误:

import tensorflow as tf
Traceback (most recent call last):

  File "<ipython-input-2-41389fad42b5>", line 1, in <module>
    import tensorflow as tf

  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *

  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow

  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)

ImportError: Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 205, 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:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

我对此非常新,所以任何答案都表示赞赏。

提前致谢。

编辑:经过一些研究,我尝试了几件事,所以我想我应该提一下。首先,我安装了Microsoft Visual C ++ 2015 Redistributable(Update 3)。在此之后,我重新安装了CUDA toolkit 8.0和cuDNN。我还检查了cuDNN的版本是v5.1,我认为是正确的。我也尝试过pip install tensorflow-gpu,但问题仍未解决。我也尝试过没有任何问题的CPU版本。

编辑2:好的,所以我设法通过使用cuDNN v6.0解决了这个问题,尽管它在tensorflow网站上说了什么。我认为它现在有效,但我不确定。我成功地运行了'Hello Tensorflow&#39;例子我觉得现在好了。

如果有人知道为什么这个解决方案有效,我会很感激解释。

0 个答案:

没有答案