我可以在GPU上运行Keras模型吗? [英] Can I run Keras model on gpu?

查看:613
本文介绍了我可以在GPU上运行Keras模型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Keras模型,提交截止日期为36小时,如果我在cpu上训练我的模型大约需要50个小时,有没有办法在gpu上运行Keras?

I'm running a Keras model, with a submission deadline of 36 hours, if I train my model on the cpu it will take approx 50 hours, is there a way to run Keras on gpu?

我正在使用Tensorflow后端,并在未安装anaconda的Jupyter笔记本上运行它.

I'm using Tensorflow backend and running it on my Jupyter notebook, without anaconda installed.

推荐答案

是的,您可以在GPU上运行keras模型.几件事您必须首先检查.

Yes you can run keras models on GPU. Few things you will have to check first.

  1. 您的系统具有GPU(Nvidia.因为AMD尚未运行)
  2. 您已安装了Tensorflow的GPU版本
  3. 您已安装CUDA 安装说明
  4. 验证tensorflow是否正在使用GPU
  1. your system has GPU (Nvidia. As AMD doesn't work yet)
  2. You have installed the GPU version of tensorflow
  3. You have installed CUDA installation instructions
  4. Verify that tensorflow is running with GPU check if GPU is working

sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

OR

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

输出将是这样的:

[
  name: "/cpu:0"device_type: "CPU",
  name: "/gpu:0"device_type: "GPU"
]

完成所有这些操作后,您的模型将在GPU上运行:

Once all this is done your model will run on GPU:

要检查keras(> = 2.1.1)是否使用GPU:

To Check if keras(>=2.1.1) is using GPU:

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

祝一切顺利.

这篇关于我可以在GPU上运行Keras模型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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