我知道之前有人问过这个问题。我相信我尝试了其他StackOverflow问题(On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error)中写的所有内容。新的TensorFlow 1.7需要CUDA Toolkit 9.0和cuDNN v7.0(我将其添加到我的环境路径中)。我还安装了最新版本的Visual Studio 17.我重新安装了Python 3.5;蟒蛇; CUDA工具包9.0; cuDNN v7.0。你认为它是因为新的VS工作室不兼容吗?
这是我得到的错误:
import tensorflow as tf
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
return importlib.import_module(mname)
File "C:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import * # pylint: disable=redefined-builtin
File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
return importlib.import_module(mname)
File "C:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
答案 0 :(得分:2)
由于处理器的生成,可能会导致此错误。我只为CPU模式遇到了同样的错误。检查了2台机器:win 7 pro,i7 1366 socket和win 7 home with i5 1366 socket同样的输出。 问题是Tensorflow r1.7似乎需要AVX支持。如果没有切换到Tensor Flow 1.5,请检查您的处理器是否支持AVX
对于本机安装(python 3.5或python 3.6)(Tensor Flow r1.5 CPU)
pip3 install tensorflow==1.5
对于anaconda(Tensor Flow r1.5 CPU)
conda create -n your_env_name pip python=3.5 (or 3.6)
在下一行
activate your_env_name
最后安装Tensorflow 1.5
pip install --ignore-installed tensorflow==1.5
对我来说,有两种方法可以毫无问题地在2台机器上工作 我不知道你是否正在处理GPU,因为我是新手,我的图形功能不够强大。
享受!