Distributed training divides model computation and data processing across multiple processes or devices. In PyTorch DistributedDataParallel (DDP), each GPU works on different data while synchronized gradients improve a shared model, making training faster than single-GPU or simpler parallel approaches. section 7.8.1
A practical DDP training workflow is:
- Instantiate the model, then wrap it with PyTorch DistributedDataParallel. section 7.8.1
- Initialize distributed communication and assign each process its device and rank. section 7.8.2
- Load data, run forward and backward passes, compute loss, and update parameters on each process’s data subset. section 7.8.1 section 7.8.2
- Synchronize processes at required points, such as a dist.barrier() before the next epoch, then destroy the process group after training. section 7.8.1
- Choose NCCL for GPU collective communication or Gloo for CPU training, and provide sufficient machine or cluster resources. section 7.8.1
Two-process MNIST training
A PyTorch example initializes a DDP environment with NCCL, loads MNIST through DataLoader, assigns each spawned process a CUDA device, wraps a Flatten-plus-Linear network in DistributedDataParallel, and trains across two GPUs. A related GCN example uses the Amazon Products dataset and NeighborLoader on a dual-GPU Kaggle notebook. section 7.8.2
Figure 7.3 Process diagram for initiating and running a training with multiple processor devices
Use the process diagram to follow initialization and execution across multiple processor devices. section 7.8.2





