在tensorflow的学习中,想使用tensorflow-gpu版的学习,充分利用计算机。但是跟网上很多博主的方法安装gpu,cuda是安装成功了,但是却一直报以下一个错误。
楼主的配置信息是win10 cuda8.0 cudnn 5.1
(tensorflow) C:\Users\Administrator>python
Python 3.6.3 |Anaconda, Inc.| (default, Nov 8 2017, 15:10:56) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: 找不到指定的模块。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 22, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "D:\ProgramFiles\Anaconda\envs\tensorflow\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: 找不到指定的模块。
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.
在找了很多方法后,终于找到了原因所在,原来是win10中环境配置的原因,win10中,不仅要添加环境变量path的值,还需要在PATHEXT中添加.DLL否则系统就无法加载指定的模块,即使你的文件中有.dll文件。具体如下图: