【发布时间】:2017-07-17 07:36:13
【问题描述】:
我在 Windows 上运行了 Keras 和 Theano 安装(通过关注 tutorial)。现在我尝试将后端切换到Tensorflow,效果很好。
我唯一遇到的问题是 Tensorflow does not detect my GPU,而 Theano 则相反:
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 后端运行时,它运行得非常好:
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 的文件,其内容如下:
[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
也许缺少类似的东西,或者我需要add environment variables like for Theano?。在 Linux 上可能是 related question (?)。
完整的安装日志(包括一个奇怪的异常)可以在Gist 中找到。
任何想法,如何让 GPU 对 Tensorflow 可见?
【问题讨论】:
标签: python windows tensorflow gpu keras