[英]How to use GPU and CPU in tensorflow (keras)?
我正在运行带有 tf.keras 的相当内存密集型(估计约为 6GB)GAN model,我的 GPU 无法处理(报告似乎无法处理) 有没有办法用系统 memory 支持我的 4GB GPU memory? 还是一种在 GPU 和 CPU 之间共享计算工作的方法?
有关更多信息,请参阅我几天前提出的这个问题的非常详细的版本(没有回应,因此这个问题): TF model 在切换到 GPU 后不再预测
In tensor flow to train a model with a gpu
is the same with any operating system when using python keras
you train the model you wrap your training function in a with
statement specifying the gpu number
as a argument for the tf.device method
这是代码的模板:
import tensorflow as tf
with tf.device('/device:GPU:<The gpu number>'):
history = model.fit(<your traning info>)
否则,如果您缺乏诸如 RAM CPU GPU 之类的资源,请尝试使用google colab一个免费环境来编程张量流,并免费访问许多 GPU 的 CPU 和 RAM
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.