没有名为'_pywrap_tensorflow_internal'的模块

时间:2017-05-20 00:28:01

标签: python windows dll tensorflow

在尝试验证tensorflow-gpu的安装时,我在尝试执行“import tensorflow as tf”时遇到ImportError。我在Windows 7上使用Quadro K620。使用pip安装了Tensorflow。

以下是堆栈跟踪:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\aagarwal>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_hel
per
    return importlib.import_module(mname)
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\importlib\_
_init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, 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 906, 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:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_hel
per
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\importlib\_
_init__.py", line 126, in import_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:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\__init__.py", line 51, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_hel
per
    return importlib.import_module(mname)
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\importlib\_
_init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, 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 906, 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:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_hel
per
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\importlib\_
_init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
>>>

我已经查看了多个其他堆栈溢出帖子,其中包括纠正路径,但我无法解决此问题。

10 个答案:

答案 0 :(得分:5)

我今天遇到了同样的问题,请切换到适用于Windows的cuDNN v5.1库,而不是@mickdelaney建议然后尝试

  1. 检查CUDA的环境设置,通常CUDA的所有设置都已添加到Windows环境

  2. 将cuDNN的binlibinclude中的文件分别复制到CUDA的binlibinclude。通常目录是C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA

  3. 然后您可以导入tensorflow并运行您的代码。祝你好运!

答案 1 :(得分:5)

我找到了适用于CPU的解决方案:它对我有用

如有必要,只需运行以下命令,然后对其进行更新

pip install tensorflow==1.5

答案 2 :(得分:2)

答案 3 :(得分:2)

您可以卸载当前版本的tensorflow并使用代码尝试低版本,如TensorFlow 0.12

pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl

https://blog.csdn.net/baidu_36669549/article/details/79734590

答案 4 :(得分:1)

安装CUDA驱动程序后,您必须下载cuDNN并将其释放。之后,您可以将cudnn64_5.dll复制到PATH 如果这不起作用,请将cudnn64_5.dll移至 NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin然后再试一次。否则你会遇到一些错误。

答案 5 :(得分:0)

安装cuDNN 5.1后仍然出现此错误(是的,我已正确设置了PATH)。我最好从this site安装tensorflow_gpu。这需要cuDNN 6.0,而不是5.1。不幸的是,他们目前只有Tensorflow 1.1用于GPU系统。

答案 6 :(得分:0)

我是中国人,所以我的英语很差,而且我的答案是你使用cudnn 7或6或5,你必须在复制文件后将dll从cudnn64_x.dll重命名为cudnn64_6.dll。 也许很快,您需要将dll重命名为7或8或9。

答案 7 :(得分:0)

我和anaconda有同样的错误,之前通过anaconda安装了另一个程序。通过conda-forge再次安装工作:conda install -c conda-forge tensorflow

答案 8 :(得分:0)

这一切都与您的视频芯片/卡以及TF VERSION的CPU兼容性有关! Tensor Flow的当前版本是1.8,在我的两台机器上都崩溃了。

我有一台使用I5 CPU和英特尔视频芯片的win7网关笔记本电脑。我的台式机win7单元配备AMD Phenom II和AMD Radeon HD5450视频卡。 I5笔记本需要TensorFlow的V1.6,而台式机AMD则需要V1.5。我没有可用于运行ANN的GPU,所以我不知道这会如何影响它。

这是PIP安装的命令行:pip install --upgrade tensorflow == 1.5.0(或您需要的任何其他版本)。这将卸载您的当前版本,然后安装指示的版本。

构建或复制一个小的TensorFlow脚本,然后在命令窗口中运行它。打开第二个命令窗口并安装其他版本。我建议从1.5开始并逐步提高。

答案 9 :(得分:0)

唯一适用于我的方法(Windows 10)是: 安装Microsoft Visual C++ 2015 Redistributable Update 3 如果您有新的计算机设置,则可能会错过。