@ptrblck So I did  try your suggestion in the following way:
if torch.distributed.is_available() and torch.distributed.is_initialized():
   if os.environ['RANK'] == 0:
      torch.save(checkpoint)
else:
      torch.save(checkpoint)

But still I’m getting the same error:

image.png1111×100 36.1 KB