Ultralytics YOLO27: Join the waitlist.
License YOLO
Back to Ultralytics Glossary

Distributed Training

Distributed training splits model training across many GPUs or machines with data, sharded, tensor, or pipeline parallelism. Covers DDP, FSDP, and scaling.

Distributed training spreads the work of training one model across multiple processors, usually GPUs or TPUs in one machine or across a cloud or on-premise cluster, so that training finishes sooner or a model too large for one device's memory can be trained at all. The devices exchange gradients, activations, or parameter shards over fast interconnects using communication libraries such as NVIDIA NCCL. It is how modern foundation models and large language models are trained, and it also shortens everyday object detection training on multi-GPU workstations.

How Distributed Training Works#

Data parallelism is the most common strategy. Every GPU holds a full replica of the model, processes its own slice of each batch of training data, and joins an all-reduce operation that averages the gradients so every replica applies the same gradient descent update. PyTorch's DistributedDataParallel (DDP) overlaps that communication with the backward pass. The global batch size is the per-GPU batch times the number of GPUs, so the learning rate usually has to scale with it: Goyal et al. trained ResNet-50 on ImageNet in one hour on 256 GPUs with a batch of 8,192 images, using a linear scaling rule and a warmup phase, at about 90% scaling efficiency from 8 to 256 GPUs.

Sharded data parallelism cuts the memory cost of those replicas. ZeRO and PyTorch's Fully Sharded Data Parallel (FSDP) split the parameters, gradients, and optimizer states across GPUs and gather each layer's full weights only while that layer is computing, so the memory each GPU needs falls as GPUs are added.

Model parallelism splits the neural network itself. Tensor parallelism divides individual matrix multiplications across GPUs, pipeline parallelism assigns consecutive layers to different GPUs and streams micro-batches through them, context parallelism splits long sequences, and expert parallelism places the experts of a mixture of experts model on different GPUs. Frameworks such as Megatron-LM combine these with data parallelism to train models with hundreds of billions of parameters.

Multi-GPU Training in Practice#

Communication is the main overhead: all-reduce traffic grows with model size, so GPUs linked by NVLink within a node scale better than nodes connected over slower networks. Batch normalization statistics are computed per GPU unless layers are converted to synchronized batch normalization, which matters when each GPU's slice of the batch is small. Ultralytics YOLO26 runs multi-GPU training through DDP: passing several device IDs launches one process per GPU with torch.distributed.run, using the NCCL backend on CUDA, and splits the batch value evenly across the GPUs.

from ultralytics import YOLO

# Load a pretrained YOLO26 model
model = YOLO("yolo26n.pt")

# Train on GPUs 0 and 1 with DDP; batch=32 gives each GPU 16 images per step
results = model.train(data="coco8.yaml", epochs=100, imgsz=640, batch=32, device=[0, 1])

Real-World Applications#

  • Large Language Models: Meta trained Llama 3 405B on up to 16K H100 GPUs, combining tensor, pipeline, context, and data parallelism in what its authors call 4D parallelism.
  • Autonomous Vehicles: Perception teams train detection and segmentation models on large archives of camera, lidar, and radar recordings from vehicle fleets, which is only practical on large GPU clusters.
  • Medical Image Analysis: High-resolution 3D CT and MRI volumes strain the memory of a single GPU, and spreading batches or model shards across GPUs makes larger volumes and models trainable.
  • Federated Learning: Federated learning also trains across many devices, but the data stays on phones, hospitals, or other clients for privacy, and only model updates travel to a central server. Distributed training gathers data in one cluster to maximize speed.
  • Split Learning: Split learning divides a model between a client and a server so raw data never leaves the client, trading extra communication for privacy.
  • Gradient Accumulation: Gradient accumulation sums gradients over several small batches before one update, matching a large batch's math on one GPU at the cost of time, while data parallelism computes those batches simultaneously on several GPUs.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning