TensorFlow 1.0在Windows上看不到GPU(但Theano可以) [英] TensorFlow 1.0 does not see GPU on Windows (but Theano does)
问题描述
我正在安装Keras& Windows上的Theano(遵循此教程).现在,我尝试将后端切换为 Tensorflow ,它工作得很好.
I have a running installation of Keras & Theano on Windows (by following this tutorial). Now I've tried to switch the backend to Tensorflow which worked quite fine.
我唯一的问题是 Tensorflow无法检测到我的GPU ,而Theano则这样做:
The only issue I have, is that Tensorflow does not detect my GPU, which Theano in contrast does:
from tensorflow.python.client import device_lib
def get_available_gpus():
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos if x.device_type == 'GPU']
没有任何结果,但是与Theano后端一起运行时,效果很好:
yields no results but when running with Theano backend, it works quite nicely:
C:\Programming\Anaconda3\python.exe D:/cnn_classify_cifar10.py
Using Theano backend.
DEBUG: nvcc STDOUT nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
mod.cu
Creating library C:/Users/Alex/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-3.5.2-64/tmpgsy496fe/m91973e5c136ea49268a916ff971b7377.lib and object C:/Users/Alex/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-3.5.2-64/tmpgsy496fe/m91973e5c136ea49268a916ff971b7377.exp
Using gpu device 0: GeForce GTX 770 (CNMeM is enabled with initial size: 80.0% of memory, cuDNN 5005)
显然缺少一些配置,但是我不知道是什么.为了让Theano正常运行,我需要一个名为~/.theanorc
的文件,其中包含以下内容:
Apparently there is some configuration missing, but I don't know what. For Theano to run correctly, I needed a file called ~/.theanorc
with the following content:
[global]
device = gpu
floatX = float32
[cuda]
root = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0
[nvcc]
flags=-LC:C:\Programming\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\libs
也许缺少类似的东西,或者我需要添加环境像Theano这样的变量?.可能相关问题在Linux(?)上.
Maybe something similar is missing or maybe I need to add environment variables like for Theano?. Possibly related question on Linux (?).
完整的安装日志(其中包含一个奇怪的异常)可以在此要点中找到.
The full installation log (which included a strange exception) can be found in this Gist.
有什么想法,如何使Tensorflow可以看到GPU?
Any ideas, how to make the GPU visible to Tensorflow?
推荐答案
在同一台计算机上同时安装tensorflow和tensorflow-gpu可能会导致问题.
Installing both tensorflow and tensorflow-gpu on the same machine might cause issues at the moment.
为版本1.0安装tensorflow(仅适用于cpu)或tensorflow-gpu(仅适用于gpu)
Install either tensorflow (for cpu only) or tensorflow-gpu (for gpu only) for version 1.0
这篇关于TensorFlow 1.0在Windows上看不到GPU(但Theano可以)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!