【发布时间】:2018-03-12 23:36:48
【问题描述】:
我已经安装了 CUDA,因为我需要运行一些深度神经网络模型,但是 Tensorflow 仍然无法看到 gpu
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
它只显示 CPU。
如何让 Tensorflow 使用我的 GPU?
当我导入安装了 tensorflow-gpu 的 keras 时得到的错误日志 ImportError: Traceback (最近一次调用最后一次): 文件“C:\Users\Monviso\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 18 行,在 swig_import_helper 返回 importlib.import_module(mname) 文件“C:\Users\Monviso\Anaconda3\lib\importlib__init__.py”,第 126 行,在 import_module return _bootstrap._gcd_import(name[level:], package, level) _gcd_import 中的文件“”,第 978 行 _find_and_load 中的文件“”,第 961 行 文件“”,第 950 行,在 _find_and_load_unlocked 文件“”,第 648 行,在 _load_unlocked 文件“”,第 560 行,在 module_from_spec 文件“”,第 922 行,在 create_module _call_with_frames_removed 中的文件“”,第 205 行 ImportError: DLL load failed: 找不到指定的模块。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Monviso\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Monviso\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Monviso\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\Monviso\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: 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.
【问题讨论】:
-
您有哪些版本的 Nvidia 驱动程序和 cudNN?你安装的是什么型号的显卡?
-
你为 GPU 或 CPU 安装了张量流吗?
-
+1 对 deaspo 的评论。 tensorflow 有两个版本(如果我没记错的话,tensorflow 和 tensorflow-gpu)
-
我已经安装了两个 tensorflow 版本。我的 gpu 是 gtx960M ,因此兼容,我有 CUDA 9.0
-
@Alex:你需要去掉tensorflow CPU版本才能访问tensorflow的GPU版本。
标签: python tensorflow