111344:

there are some discussions on how to calculate loss,it seems that DDP will automatically do batchsize average operation on loss,so do I need to manually average the loss?


No, you don’t need to manually average the loss. When using DDP, losses are local to every process, and DDP will automatically average gradients for all parameters using AllReduce communication.

My loss function is defined as follows：
loss = torch.norm(target_flow - input_flow, 2, 1)/batch_size

The batch_size here is the per-process input batch size, right?