DDP Gradient Synchronization
Spot why gradients are not synced across processes in this DDP setup.
Codepython
import torch
from torch.nn.parallel import DistributedDataParallel as DDP
def build(rank):
model = MyModel().to(rank)
# ready for distributed data-parallel training
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)
return model, optimizerWhy won't gradients be synchronized across GPUs in this code?