我正在尝试在新的Windows系统中安装tensorflow-gpu。但是遇到了这个错误
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\user\AppData\Local\Programs\Python\Python36\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 "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\imp.py", line 343, in load_dynamic
return _load(spec)
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 "<stdin>", line 1, in <module>
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\user\AppData\Local\Programs\Python\Python36\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 "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
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.
这个问题曾经被问过,我已经解决了,但是我无法弄清楚为什么它不起作用。
Tensorflow on windows - ImportError: DLL load failed: The specified module could not be found
https://github.com/tensorflow/tensorflow/issues/10033
根据这篇文章,我已将所有路径添加到环境变量 https://medium.com/@viveksingh.heritage/how-to-install-tensorflow-gpu-version-with-jupyter-windows-10-in-8-easy-steps-8797547028a4
我使用的版本是
Python: 3.6.7
CUDA: 10.0.130
cuDNN: 7.3.1
答案 0 :(得分:2)
我建议您尝试使用Anaconda
总结: 1.安装Miniconda或Anaconda,然后转到“ Anaconda Prompt”:简单使用Windows并在安装后开始编写“ anaconda”:它应该出现。 2.现在,只需运行:
conda create --name tf_gpu tensorflow-gpu
完成!可以肯定的是,您可以对其进行测试:
在“ Anaconda提示”中:
Activate environment using ‘activate tf_env’.
Go to python console using ‘python’
在Python中,只需编写:
将tensorflow导入为tf sess = tf.Session(config = tf.ConfigProto(log_device_placement = True))
有关您卡的信息应出现。 现在,只需在IDE中创建一个新项目,选择“现有解释器”,选择我们刚刚创建的虚拟环境(“ tf_gpu”),项目中的新文件将在gpu上运行。
希望我能帮上忙!多亏了Harveen Singh(我尝试了许多教程,然后才看到有效且简单的教程)
答案 1 :(得分:1)