我正在 google cloud ml-engine 上运行一个非常大的 Tensorflow 模型。
使用缩放层 basic_gpu
(使用 batch_size=1
)时,我收到如下错误:
Resource exhausted: OOM when allocating tensor with shape[1,155,240,240,16]
因为模型太大,无法容纳在一个 GPU 中。
使用提供 4 个 GPU 的 comple_model_m_gpu
层,我可以在 4 个 GPU 之间分散操作。
但是,我记得读到过,GPU 之间的通信速度很慢,可能会造成训练瓶颈。这是真的吗?
如果是这样,是否有推荐的方法在 GPU 之间传播操作来防止此问题?
最佳答案
我推荐以下指南:
来自指南:
The best approach to handling variable updates depends on the model, hardware, and even how the hardware has been configured.
基于指南的一些建议:
- 尝试使用具有 16 GB RAM 的 P100(相比之下,K80s 为 12 GB)。它们的速度也明显更快,尽管它们的成本也更高
- 将变量置于 CPU 上:
tf.train.replica_device_setter(worker_device=worker, ps_device='/cpu:0', ps_tasks=1)
关于multithreading - tensorflow 。如何在 GPU 之间分配操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47835625/