我可以在GPU上运行Keras模型吗?

编程入门 行业动态 更新时间:2024-10-26 00:24:43
本文介绍了我可以在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.

  • 您的系统具有GPU(Nvidia.因为AMD尚未运行)
  • 您已安装了Tensorflow的GPU版本
  • 您已安装CUDA 安装说明
  • 验证tensorflow是否正在使用GPU 检查GPU是否正常工作
  • your system has GPU (Nvidia. As AMD doesn't work yet)
  • You have installed the GPU version of tensorflow
  • You have installed CUDA installation instructions
  • 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模型吗?

    本文发布于:2023-06-01 10:30:37,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/413005.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:模型   GPU   Keras

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!