[英]Tensorflow ImportError: No module named '_pywrap_tensorflow_internal' on Windows 10
I am doing the self driving course with Udacity. 我正在和Udacity一起做自驾车课程。 There is a common environment which I launched in windows 10 and I was able to run tensorflow fine but I want to use the GPU.
我在Windows 10中启动了一个共同的环境,我能够运行tensorflow,但我想使用GPU。
My GPU is listed as compatible (GTX 950M). 我的GPU被列为兼容(GTX 950M)。
I followed the tensorflow instructions on windows 10 to add the GPU: 我按照Windows 10上的tensorflow指令添加GPU:
https://www.tensorflow.org/install/install_windows https://www.tensorflow.org/install/install_windows
and downloaded and installed cuda_8.0.61_win10 并下载并安装了cuda_8.0.61_win10
Next I restarted my environment. 接下来我重新启动了我的环境。 I checked to see it was working with the simple python program:
我查看它是否正在使用简单的python程序:
import tensorflow as tf
# Create TensorFlow object called tensor
hello_constant = tf.constant('Hello World!')
with tf.Session() as sess:
# Run the tf.constant operation in the session
output = sess.run(hello_constant)
print(output)
It executed fine as follows: 它执行得很好,如下:
(carnd-term1) D:\SelfDrivingCar\tensor-exp>python hello.py
b'Hello World!'
Next I installed the gpu version of tensorflow: 接下来我安装了tensorflow的gpu版本:
(carnd-term1) D:\SelfDrivingCar\CarND-Traffic-Sign-Classifier-Project>pip install tensorflow-gpu
Collecting tensorflow-gpu
Downloading tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl (48.5MB)
100% |################################| 48.6MB 16kB/s
Requirement already satisfied: six>=1.10.0 in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from tensorflow-gpu)
Requirement already satisfied: protobuf>=3.2.0 in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from tensorflow-gpu)
Requirement already satisfied: wheel>=0.26 in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from tensorflow-gpu)
Requirement already satisfied: werkzeug>=0.11.10 in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from tensorflow-gpu)
Requirement already satisfied: numpy>=1.11.0 in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from tensorflow-gpu)
Requirement already satisfied: setuptools in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from protobuf>=3.2.0->tensorflow-gpu)
Installing collected packages: tensorflow-gpu
Successfully installed tensorflow-gpu-1.1.0
I reran hello.py and got the following 我重新问好了hello.py并得到了以下内容
(carnd-term1) D:\SelfDrivingCar\tensor-exp>python hello.py
Traceback (most recent call last):
File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "d:\ProgramData\Anaconda3\envs\carnd-term1\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 "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "d:\ProgramData\Anaconda3\envs\carnd-term1\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 "hello.py", line 1, in <module>
import tensorflow as tf
File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "d:\ProgramData\Anaconda3\envs\carnd-term1\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 "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "d:\ProgramData\Anaconda3\envs\carnd-term1\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_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I removed the environment and repeated the whole process using the following command : 我删除了环境并使用以下命令重复整个过程:
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl
and got the same result. 并得到了相同的结果。
The following doesn't work ( Cannot import Tensorflow for GPU on Windows 10 ) as there is no file named cudnn64_6.dll in the directory listed. 以下不起作用( 无法在Windows 10上导入GPU的Tensorflow ),因为列出的目录中没有名为cudnn64_6.dll的文件。
Any ideas why the Import Error is occurring? 任何想法导致导入错误的原因?
You need to install cudnn. 你需要安装cudnn。 Only version 5.1 is officially supported right now.
目前仅正式支持5.1版。 Don't know if the renaming trick for 6.0 mentioned at:
不知道6.0中的重命名技巧是否提到:
Cannot import Tensorflow for GPU on Windows 10 无法在Windows 10上导入GPU的Tensorflow
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.