when I train a model using DDP in 4 GPUs and evaluate it  in one GPU with args.local_rank==0, I want to broadcast the top1 to other GPUs. but I got the deadlock. The GPUs (local_rank=1,2,3) just enter the next command without blocking to get the broadcast results.
The code is shown below. It was execuated after finishing training one epoch.
if args.local_rank == 0:
      top1, top5 = test(net, testloader, criterion, False)
torch.distributed.broadcast(torch.tensor(top1).cuda(args.local_rank),src=0, async_op=False)
print("local rank:{}, top1:{}".format(args.local_rank, top1))

The result is shown below. The process was hanged after print the following information:

image1122×328 22.9 KB

Is there anyone who met the same problem?