windows 机器中未正确安装 Tensorflow-gpu

Tensorflow-gpu not installed properly in windows machine

我正在尝试在我的新 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.

之前有人问过这个问题,我已经解决了这些问题,但我无法弄清楚为什么这不起作用。

https://github.com/tensorflow/tensorflow/issues/10033

我已经根据这个添加了环境变量的所有路径post 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

TF 支持 CUDA 9.0。

按照这些说明进行操作

https://www.tensorflow.org/install/gpu

https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/

我建议你尝试使用 Anaconda

See this tutorial

总结: 1.安装Miniconda或Anaconda然后进入"Anaconda Prompt": simple use Windows and start writing "anaconda" 安装后:应该会出现。 2. 现在,只需 运行:

conda create --name tf_gpu tensorflow-gpu

完成!可以肯定的是,你可以测试它:

在"Anaconda Prompt"中:

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 中创建一个新项目,选择 "Existing Interpreter",选择我们刚刚创建的虚拟环境 ("tf_gpu"),项目中的新文件将 运行 在GPU上。

希望我有所帮助!感谢 Harveen Singh(我尝试了很多教程,然后才看到一个有效且简单的教程)