# Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour

Large minibatches can match small-batch ImageNet accuracy

Priya Goyal, Piotr Dollár, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola and 3 more · arXiv · 2017-6-8

- **Problem** Distributed SGD needs large minibatches to stay efficient, but large minibatches were thought to hurt optimization. Before this work, no results showed accuracy holding at minibatches as large as 8192 images.
- **Method** The authors scale the learning rate linearly with minibatch size and add gradual warmup over the first 5 epochs. Gradual warmup ramps the rate up from 0.1 to 3.2 instead of jumping to it.
- **Results** With an 8k minibatch, ResNet-50 reaches 23.74% ±0.09 top-1 validation error. The 256 minibatch baseline reaches 23.60% ±0.12.

## Why large minibatches are needed

Training ResNet-50 with a 256-image minibatch on 8 Tesla P100 GPUs takes 29 hours, which slows research and development considerably. Spreading work over many workers is efficient only when each worker keeps a large share of the computation, and keeping that share fixed means the global minibatch must grow with the number of workers.

Growing the minibatch that far raises optimization questions, and the authors note that no earlier result showed generalization holding at minibatches as large as 8192 or that such models could be trained in so little time.

## The linear scaling rule and its reasoning

Minibatch SGD averages the per-sample gradients of a minibatch and moves the weights by the learning rate times that average. The linear scaling rule keeps this update form and changes only the learning rate: when the minibatch size is multiplied by k, the learning rate is multiplied by k as well, while weight decay and the other hyper-parameters stay unchanged.

The justification compares k small-batch steps at learning rate η with one large-batch step covering the same k minibatches at learning rate \\( \\hat{\\eta} \\). If the gradient barely changes over those k steps, then setting \\( \\hat{\\eta} = k\\eta \\) makes the two updates approximately equal. The authors call this a strong assumption.

The assumption fails in two places the authors identify: early in training, when the network changes quickly, and when the minibatch becomes too large, where accuracy falls off sharply. The first failure is addressed by warmup, and the second sets a practical ceiling on minibatch size.

The same scaling had been used by Krizhevsky, who reported a 1% increase of error when going from minibatch 128 to 1024, so the rule itself is not new. Li tested minibatches up to 5120 without a loss after convergence but did not give a hyper-parameter-free rule, and Bottou et al. argue that the learning rate should have a maximum independent of minibatch size, which motivates warmup.

## Warmup for the first epochs

The earlier warmup from the ResNet work holds a low constant learning rate for the first few epochs of training. In the experiments here, the constant form used η for the first 5 epochs and then switched to η̂ = kη, and with a large k the switch caused training error to spike.

Gradual warmup starts at η and increases the learning rate by a fixed amount at each iteration until it reaches \\( \\hat{\\eta} = k\\eta \\) after 5 epochs. This avoids the sudden jump that the constant form creates, and the authors report that the results are robust to the exact warmup length.

## Batch normalization ties the loss to the per-worker batch

Batch Normalization computes statistics over the minibatch, so the loss of one sample depends on the other samples in its batch, which breaks the per-sample loss assumed in the SGD formulation. Changing the batch size over which these statistics are computed therefore changes the loss being optimized.

Distributed training keeps the per-worker batch fixed at n = 32 and enlarges the total minibatch by adding workers, which can be read as drawing k independent BN batches. The authors treat the BN batch size as a hyper-parameter of Batch Normalization rather than of distributed training, and they do not compute BN statistics across all workers.

## Implementation details that change the solver

Weight decay enters the update as the gradient of an L2 term, a term added separately from the sample-dependent gradient. For that reason, scaling the cross-entropy loss is not the same as scaling the learning rate, since the weight decay term does not scale with the loss.

In the momentum SGD form that absorbs the learning rate into the update buffer, the history term has to be rescaled when the learning rate changes, and the authors call this the momentum correction. They found it especially important when the learning rate rises sharply, because an unscaled history term becomes too small and training becomes unstable.

When the rate falls the correction matters less.

Each worker averages its loss over its own n samples, so the gradient must be normalized by the total kn rather than by n. Because allreduce sums instead of averaging, the 1/k factor is best absorbed into the loss so that only its gradient is scaled. Each epoch should use one random shuffle that is split across all k workers, so the workers together see the training data as a single shuffled pass.

## Gradient aggregation across servers

Aggregation runs as soon as a layer's gradient is ready and overlaps with backprop for the next layer, because there is no data dependency between gradients of different layers. The allreduce leaves every GPU with the sum of all k gradients, and the work is split into three phases: summing the 8 GPUs inside each server, exchanging and summing across servers, and broadcasting back to each GPU.

Inside a server, the reduction and broadcast use NCCL for buffers of 256 KB or more, and a copy-to-host and CPU reduction otherwise, which leaves GPU time for backprop. Across servers the study used recursive halving and doubling, which takes 2 log2(p) steps, and the bucket (ring) algorithm, which takes 2(p-1) steps. On 32 servers with 256 GPUs, halving and doubling gave a 3× speedup over the ring algorithm.

For server counts that are not a power of two, the binary blocks variant adds two communication steps, and the authors saw no significant slowdown from the resulting load imbalance. The allreduce algorithms are implemented in Gloo, which supports multiple communication contexts so that several allreduce instances can run in parallel.

The servers use Mellanox ConnectX-4 50Gbit Ethernet cards and Wedge100 switches, with Tesla P100 GPUs connected by NVLink.

## Experimental setup and error reporting

The main benchmark is the 1000-way ImageNet classification task, with about 1.28 million training images and 50,000 validation images. The model is a ResNet-50 variant with stride-2 convolutions on 3×3 layers, trained with Nesterov momentum of 0.9 and a weight decay of 0.0001 that is not applied to the BN coefficients.

The last BN layer of each residual block starts with γ = 0, which lets the signal pass through the identity shortcut at the start of training.

Each model's error is the median of its final 5 epochs, and the mean and standard deviation are taken over 5 independent runs. The small-minibatch baseline with 8 GPUs and 256 images reaches 23.60%±0.12 top-1 error, compared with 24.01% for fb.resnet.torch and 24.7% for the original ResNet paper under weaker augmentation.

## ImageNet accuracy with an 8k minibatch

The large-minibatch runs use k = 256 and n = 32, which gives a minibatch of 8k, with η = 3.2 from the linear scaling rule, and all other hyper-parameters are held fixed. Three warmup choices are compared: none, constant warmup at η = 0.1 for 5 epochs, and gradual warmup that climbs from 0.1 to 3.2 over 5 epochs.

Without warmup, the 8k model reaches 24.84 ±0.37 top-1 validation error, and constant warmup gives 25.88 ±0.56, while gradual warmup gives 23.74 ±0.09 against 23.60 ±0.12 for the baseline. The training curves show that the constant form degrades results, because the error spikes after warmup and does not recover.

With gradual warmup, the large-minibatch training error starts higher during warmup but follows the baseline closely after about 20 epochs. The gradual warmup validation error is within 0.14% of the baseline, and the authors attribute the roughly 1.2% higher error without warmup to a roughly 2.1% higher training error rather than to poor generalization.

Validation error starts to match the baseline after the second learning rate drop, and it matches earlier when BN statistics are recomputed instead of using running averages. Taken together, the authors read the 8k gap as an optimization problem that gradual warmup solves, not a generalization problem.

## Alternative learning rate rules and ResNet-101

Keeping η at 0.1 for the 8k minibatch gives 41.67±0.10 top-1 error, and the square root rule with 0.1 times √32 gives 26.22±0.03. The linear rule at 0.1 times 32 gives 23.74±0.09, so the linear choice is the one that matches the baseline among the options tried.

For 256 minibatches, changing η from 0.1 to 0.2 changes the shape of the training curve even when the final error is similar, whereas the linear scaling rule keeps curves matched across batch sizes.

The authors read the larger gain at 8k as a sign that large minibatches are more affected by optimization difficulty.

For ResNet-101, the 256 baseline reaches 22.08±0.06 and the 8k minibatch with η = 3.2 reaches 22.36±0.09, a 0.28% higher error. ResNet-101 with an 8k minibatch trains in 92.5 minutes on 256 Tesla P100 GPUs in this implementation.

## Whether a larger dataset moves the limit

ImageNet-5k extends ImageNet-1k to 6.8 million images by adding 4k categories from ImageNet-22k, and error is still measured on the ImageNet-1k validation set. The curve for ImageNet-5k is qualitatively similar to the ImageNet-1k curve, with a fixed 90 epoch schedule.

The authors conclude that a five times larger dataset does not noticeably shift the maximum useful minibatch size, although the precise relation between error, minibatch size and dataset information content is left open.

## Transfer to COCO detection and segmentation

Mask R-CNN is initialized from ResNet-50 models pre-trained on ImageNet with minibatches from 256 to 16k and then trained on COCO, with results reported on the 5k image minival split. Mask R-CNN is unusual here because its layers use different effective minibatch sizes, with two images per GPU and 512 regions of interest per image.

Box AP is 35.9±0.1 with pre-training at 256 and 35.8±0.1 at 8k, and mask AP is 33.9±0.1 and 33.9±0.2 at the same sizes. At 16k, both ImageNet validation error and COCO AP deteriorate, with box AP of 35.1±0.3 and mask AP of 33.2±0.3, so the authors tie transfer quality to matching the ImageNet error.

With the linear learning rate rule applied to Mask R-CNN on 1, 2, 4 and 8 GPUs, box AP stays at 35.7, 35.7, 35.7 and 35.6, and mask AP at 33.6, 33.7, 33.5 and 33.6. These are single-model results without a reported standard deviation, and the authors take them as evidence that the rule carries over beyond classification.

## Run time and scaling efficiency

Time per iteration rises by only 12% while the minibatch grows 44 times, from 256 to 11k. Time per epoch falls from over 16 minutes to about 30 seconds, and with 352 GPUs in 44 servers one pass over the 1.28 million ImageNet training images takes about 30 seconds.

Relative to an ideal extrapolation of the 8-GPU baseline, throughput reaches about 90% scaling efficiency, and the authors note that this is with commodity Ethernet. Most of the allreduce time is hidden behind gradient computation through pipelining.

## Limits at large batch sizes

The authors place the point where accuracy degrades rapidly at about 8k on ImageNet, so the linear rule has a practical ceiling. On ImageNet-1k, validation error stays stable from 64 to 8k and then begins to increase, and beyond 64k training diverges under the linear rule.

Minibatches of 12k and larger on a single server were simulated with gradient accumulation, which the authors say gives equivalent results to distributed training. Techniques such as quantized gradients and Block-Momentum SGD were left outside the scope of the study.

The ResNet-101 result still carries a 0.28% increase at 8k, and the ImageNet-5k comparison is a single 8k versus 256 comparison.

## Paper info

- **Authors**: Priya Goyal, Piotr Dollár, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, Andrew Tulloch, Yangqing Jia, Kaiming He
- **Venue**: arXiv · Preprint
- **First published**: 2017-6-8
- **Added**: 2026-11-12
- **Updated**: 2018-4-30
- **Version**: v2
- **arXiv**: 1706.02677
- **Category**: cs.CV · cs.DC · cs.LG
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1706.02677v2) · [PDF ↗](https://arxiv.org/pdf/1706.02677v2)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Priya Goyal, Piotr Dollár, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, Andrew Tulloch, Yangqing Jia, Kaiming He (2017). Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour. arXiv:1706.02677v2. https://arxiv.org/abs/1706.02677v2

**BibTeX**

```
@misc{goyal2017accurate,
  title = {{Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour}},
  author = {Priya Goyal and Piotr Dollár and Ross Girshick and Pieter Noordhuis and Lukasz Wesolowski and Aapo Kyrola and Andrew Tulloch and Yangqing Jia and Kaiming He},
  year = {2017},
  eprint = {1706.02677},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1706.02677v2}
}
```

## Other paper commentary

- [Image Segmentation Using Deep Learning: A Survey](https://refivu.com/en/papers/c5b4071c-1e13-4bda-97cd-37556fea547e-image-segmentation-using-deep-learning-a-survey.md)
- [Residual Attention Network for Image Classification](https://refivu.com/en/papers/a2dac1b2-ffde-41af-9f9c-c9914f383632-residual-attention-network-for-image-classification.md)
- [DeCAF: A Deep Convolutional Activation Feature for Generic Visual Recognition](https://refivu.com/en/papers/b018056b-58d2-42cc-9184-ed3588d7abd4-decaf-a-deep-convolutional-activation-feature-for-generic.md)
- [Rethinking Semantic Segmentation from a Sequence-to-Sequence Perspective with Transformers](https://refivu.com/en/papers/c0f3cbcf-d34f-4a38-a72f-084577c0ea46-rethinking-semantic-segmentation-from-a-sequence-to-sequence.md)
- [CenterNet: Keypoint Triplets for Object Detection](https://refivu.com/en/papers/f08ac102-1d96-4756-a172-5c1d6ab4ebfb-centernet-keypoint-triplets-for-object-detection.md)
- [SlowFast Networks for Video Recognition](https://refivu.com/en/papers/f84c7c1a-0798-4d78-bcc9-020ba5b4e4b1-slowfast-networks-for-video-recognition.md)
- [Past, Present, and Future of Simultaneous Localization And Mapping: Towards the Robust-Perception Age](https://refivu.com/en/papers/52381e81-8cdd-4551-89ee-d6c7630fb938-past-present-and-future-of-simultaneous-localization-and.md)
- [Estimating or Propagating Gradients Through Stochastic Neurons for Conditional Computation](https://refivu.com/en/papers/e938eef4-a963-441d-bfef-194cc6a9a9e3-estimating-or-propagating-gradients-through-stochastic.md)
- [On Calibration of Modern Neural Networks](https://refivu.com/en/papers/49c54409-e306-4419-a26c-4569bedfbd40-on-calibration-of-modern-neural-networks.md)
- [The information bottleneck method](https://refivu.com/en/papers/268a2320-65eb-4df2-b959-78f02f848cce-the-information-bottleneck-method.md)

## Terms in this paper

- [ImageNet](https://refivu.com/en/terms/5eadad128667-imagenet)
- [Batch Normalization](https://refivu.com/en/terms/2b3e5f8509f6-batch-normalization)
- [COCO](https://refivu.com/en/terms/41f3215c4f4a-coco)
- [Mask R-CNN](https://refivu.com/en/terms/6da881f24c0c-mask-r-cnn)
- [Resnet-101](https://refivu.com/en/terms/e1917778abec-resnet-101)
- [box AP](https://refivu.com/en/terms/850b2f2111cb-box-ap)
- [top-1 validation error](https://refivu.com/en/terms/0b9c2d196f55-top-1-validation-error)
- [minibatch stochastic gradient descent](https://refivu.com/en/terms/ae18d9f1a915-minibatch-stochastic-gradient-descent)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/c430ecf3-8156-45a7-a3f7-eafc308c0d49-accurate-large-minibatch-sgd-training-imagenet-in-1)
