张量流。如何在 GPU 之间分配操作

Tensorflow. How to distribute ops between GPUs

我是 运行 google 云机器学习引擎上的一个非常大的 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 之间传播操作的方法来防止这个问题?

我推荐以下指南:

Optimizing for 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)

使用 Tesla P100 GPU 而不是 Tesla K80 GPU 解决了这个问题,因为 P100 有一个叫做 Page Migration Engine 的东西。

Page Migration Engine frees developers to focus more on tuning for computing performance and less on managing data movement. Applications can now scale beyond the GPU's physical memory size to virtually limitless amount of memory.