Keras不使用GPU-如何进行故障排除? [英] Keras does not use GPU - how to troubleshoot?

查看:1812
本文介绍了Keras不使用GPU-如何进行故障排除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在GPU上训练Keras模型,并以Tensorflow作为后端.

I'm trying to train a Keras model on the GPU, with Tensorflow as backend.

我已根据 https://www.tensorflow.org/install/install_windows.这是我的设置:

I have set everything up according to https://www.tensorflow.org/install/install_windows. This is my setup:

  • 我正在virtualenv环境中的Jupyter笔记本中工作.
  • 当前virtualenv环境已安装tensorflow-gpu.
  • 我已经安装了CUDA 9.1和CUDA 9.1的cudaDNN.
  • cuDNN64_7.dll位于可通过PATH变量访问的位置.
  • 我的计算机上装有最新驱动程序的NVIDIA GeForce GTX 780.
  • I'm working in a Jupyter notebook in a virtualenv environment.
  • The current virtualenv environment has tensorflow-gpu installed.
  • I have CUDA 9.1 and cudaDNN for CUDA 9.1 installed.
  • cuDNN64_7.dll is at a location which is accessible via the PATH variable.
  • I have an NVIDIA GeForce GTX 780 on my computer with the latest drivers.

但是,Tensorflow没有看到任何可用的GPU:

However, Tensorflow does not see any usable GPU:

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 5275203639471190827
]

Keras都不:

from keras import backend as K
K.tensorflow_backend._get_available_gpus()

[]

我该如何调试?我如何找出问题所在?

How can I debug this? How can I find out where the problem is?

推荐答案

检查
nvcc -V

Check
nvcc -V
and

nvidia-smi

看看它是否显示我们的GPU.

and see if it shows our gpu or not.

假设您的cuda cudnn一切都已签出, 您可能只需要
1.卸载keras
2.卸载tensorflow
3.卸载tensorflow-gpu
4.仅安装tensorflow-gpu pip install tensorflow-gpu==1.5.0
5.现在安装Keras.

Assuming your cuda cudnn and everything checks out, you may just need to
1. Uninstall keras
2. Uninstall tensorflow
3. uninstall tensorflow-gpu
4. Install only tensorflow-gpu pip install tensorflow-gpu==1.5.0
5. Install Keras now.

我遵循了这些步骤,并且keras现在使用gpu.

I followed these steps, and keras now uses gpu.

希望它在一定程度上有所帮助.

Hope it helps to some extent.

这篇关于Keras不使用GPU-如何进行故障排除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆