[论文解读] Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour
论文证明使用大批量小批量 SGD 最多到 8192,配合线性学习率缩放规则和渐进热身,可以在 256 GPU 上用 1 小时训练 ResNet-50 在 ImageNet,且保持与小批量训练相当的准确性。
Deep learning thrives with large neural networks and large datasets. However, larger networks and larger datasets result in longer training times that impede research and development progress. Distributed synchronous SGD offers a potential solution to this problem by dividing SGD minibatches over a pool of parallel workers. Yet to make this scheme efficient, the per-worker workload must be large, which implies nontrivial growth in the SGD minibatch size. In this paper, we empirically show that on the ImageNet dataset large minibatches cause optimization difficulties, but when these are addressed the trained networks exhibit good generalization. Specifically, we show no loss of accuracy when training with large minibatch sizes up to 8192 images. To achieve this result, we adopt a hyper-parameter-free linear scaling rule for adjusting learning rates as a function of minibatch size and develop a new warmup scheme that overcomes optimization challenges early in training. With these simple techniques, our Caffe2-based system trains ResNet-50 with a minibatch size of 8192 on 256 GPUs in one hour, while matching small minibatch accuracy. Using commodity hardware, our implementation achieves ~90% scaling efficiency when moving from 8 to 256 GPUs. Our findings enable training visual recognition models on internet-scale data with high efficiency.
研究动机与目标
- 为不同 minibatch 大小的超参数调优之外,推动并实现高效的大规模分布式训练。
- 证明在正确缩放的情况下,最多到 8192 的大批量可以在 ImageNet 上与小批量的准确度相匹配。
- 开发可用于分布式 SGD 的实用技术(学习率线性缩放、热身、BN 处理)。
- 提供实现指南并强调分布式 SGD 的细微差别/陷阱。
提出的方法
- 提出 Linear Scaling Rule:设学习率与 minibatch 大小 kn 成正比,其他超参数保持不变。
- 引入 Gradual Warmup:在初始化后将学习率从较小值逐步提升到目标值,以稳定早期训练。
- 解决 Batch Normalization 的影响:将 BN 统计按固定的每工作器 minibatch 大小 n=32 处理,并确保在适当的工作组内对 BN 进行计算,以保留损失函数。
- 通过 allreduce 在服务器之间进行梯度聚合,描述允许重叠通信和计算的流水线。
- 描述硬件和软件栈:在 32 台服务器上使用 256 GPUs,利用 NCCL 和 Gloo 进行高效的 allreduce,服务器之间通信通过减半/加倍来实现。
- 讨论实现细节:权重衰减处理、学习率变化时的动量校正、梯度聚合缩放,以及跨多工作器的数据洗牌。
实验结果
研究问题
- RQ1非常大的 minibatch 大小(高达 8192)是否能在 ImageNet 上保持与小批量训练相同的准确性?
- RQ2简单的学习率线性缩放规则,结合热身策略,是否能实现高效、可扩展的分布式 SGD,而不需要超参数调优?
- RQ3当 minibatch 大小缩放时,BN 统计和分布式实现细节如何影响训练?
- RQ4在分布式 SGD 中有哪些实际陷阱,以及如何在实际系统中缓解?
- RQ5所提出的技术是否能超越 ImageNet,推广到对象检测/分割等其他任务?
主要发现
- 在 ImageNet 上以 kn 为单位、批量达到 8k 的 ResNet-50,在使用渐进热身和线性缩放规则时,其 top-1 错误率几乎等同于小批量基线。
- 当 k=256 GPUs 且 n=32 时,参考学习率为 0.1 × kn/256 = 3.2,渐进热身使验证误差为 23.74% ± 0.09,接近基线 23.60% ± 0.12。
- 渐进热身稳定了大批量的优化,训练曲线在大约 20 个 epoch 后与小批量基线密切吻合。
- 当从 8 台 GPUs 增至 256 GPUs 时,系统在 1 小时内训练出 ResNet-50,且放大约 90% 的扩展效率。
- 提出策略的大批量训练可推广到更复杂的任务,如对象检测/分割(如 Mask R-CNN),且转移性能不下降。
- 一整套实现注释和细微差别(权重衰减、动量校正、梯度聚合、BN 处理和数据洗牌)对实现近线性扩展和正确优化至关重要。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。