Tensorflow 解决 No module named '_pywrap_tensorflow_internal'

版权声明:本文为博主原创文章,转载请标注出处。 https://blog.csdn.net/Yan_Joy/article/details/76094202

这个问题是我在windows上尝试安装GPU版本时出现的,系统 win10,CUDA 8.0,VS2015 com,cudnn-8.0-windows10-x64-v6.0。
官网上安装指南中Common installation problems也有提到,给出的是STACK OVERFLOW 的解答:On Windows, running “import tensorflow” generates No module named “_pywrap_tensorflow” error,主要原因是没有安装cuDDN库。

但是装了之后仍然不能解决这个问题,注意其实两个问题有所区别:“_pywrap_tensorflow”和’_pywrap_tensorflow_internal’,是不是CUDA安装出现问题了呢?在anaconda上的命令行输入nvcc是找不到相应程序的,而在系统中的命令行可以找到。
首先为了排除错误,单独在anaconda安装了python 3.5,但还是同样的问题。那么CPU版本可以吗?答案是肯定的,还是GPU哪里没配置好。
终于还是在STACK OVERFLOW上找到了答案:Cannot import Tensorflow for GPU on Windows 10
在cuda安装目录下,如:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin把cudnn的文件名改一下就可以了,cudnn64_6.dll改为cudnn64_5.dll即可。
试了一下,果然问题解决了。

阅读更多
换一批

ImportError: No module named '_pywrap_tensorflow_internal'

11-05

tensorflow==1.5.0 安装成功;继续安装gpu版本,按系统提示再安装 CUDA-9.0, cuDNN-7.0: cuda_9.0.176_win10_network以及patch1-4 / cudnn-9.0-windows10-x64-v7.3.1.20. 运行‘import tensorflow as tf’后报错: ImportError: No module named '_pywrap_tensorflow_internal'rnrn谢谢帮助rnrn ---------------------------------------------------------------------------rnImportError Traceback (most recent call last)rnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()rn 17 try:rn---> 18 return importlib.import_module(mname)rn 19 except ImportError:rnrnC:\Program Files\Anaconda3\lib\importlib\__init__.py in import_module(name, package)rn 125 level += 1rn--> 126 return _bootstrap._gcd_import(name[level:], package, level)rn 127 rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in _gcd_import(name, package, level)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in _find_and_load(name, import_)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in _load_unlocked(spec)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in module_from_spec(spec)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap_external.py in create_module(self, spec)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)rnrnImportError: DLL load failed: 找不到指定的程序。rnrnDuring handling of the above exception, another exception occurred:rnrnImportError Traceback (most recent call last)rnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in ()rn 57 rn---> 58 from tensorflow.python.pywrap_tensorflow_internal import *rn 59 from tensorflow.python.pywrap_tensorflow_internal import __version__rnrnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in ()rn 20 return importlib.import_module('_pywrap_tensorflow_internal')rn---> 21 _pywrap_tensorflow_internal = swig_import_helper()rn 22 del swig_import_helperrnrnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()rn 19 except ImportError:rn---> 20 return importlib.import_module('_pywrap_tensorflow_internal')rn 21 _pywrap_tensorflow_internal = swig_import_helper()rnrnC:\Program Files\Anaconda3\lib\importlib\__init__.py in import_module(name, package)rn 125 level += 1rn--> 126 return _bootstrap._gcd_import(name[level:], package, level)rn 127 rnrnImportError: No module named '_pywrap_tensorflow_internal'rnrnDuring handling of the above exception, another exception occurred:rnrnImportError Traceback (most recent call last)rn in ()rn----> 1 import tensorflow as tfrnrnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\__init__.py in ()rn 22 rn 23 # pylint: disable=wildcard-importrn---> 24 from tensorflow.python import *rn 25 # pylint: enable=wildcard-importrn 26 rnrnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in ()rn 47 import numpy as nprn 48 rn---> 49 from tensorflow.python import pywrap_tensorflowrn 50 rn 51 # Protocol buffersrnrnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in ()rn 72 for some common reasons and solutions. Include the entire stack tracern 73 above this error message when asking for help.""" % traceback.format_exc()rn---> 74 raise ImportError(msg)rn 75 rn 76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-longrnrnImportError: Traceback (most recent call last):rn File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helperrn return importlib.import_module(mname)rn File "C:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_modulern return _bootstrap._gcd_import(name[level:], package, level)rn File "", line 986, in _gcd_importrn File "", line 969, in _find_and_loadrn File "", line 958, in _find_and_load_unlockedrn File "", line 666, in _load_unlockedrn File "", line 577, in module_from_specrn File "", line 906, in create_modulern File "", line 222, in _call_with_frames_removedrnImportError: DLL load failed: 找不到指定的程序。rnrnDuring handling of the above exception, another exception occurred:rnrnTraceback (most recent call last):rn File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in rn from tensorflow.python.pywrap_tensorflow_internal import *rn File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in rn _pywrap_tensorflow_internal = swig_import_helper()rn File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helperrn return importlib.import_module('_pywrap_tensorflow_internal')rn File "C:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_modulern return _bootstrap._gcd_import(name[level:], package, level)rnImportError: No module named '_pywrap_tensorflow_internal'rnrnrnFailed to load the native TensorFlow runtime.rnrnSee https://www.tensorflow.org/install/install_sources#common_installation_problemsrnrnfor some common reasons and solutions. Include the entire stack tracernabove this error message when asking for help.

没有更多推荐了,返回首页