返回当前进程组的排名

torch.distributed.get_rank() # 返回当前进程组的排名

同步进程

参考 GitHub

        # if torch.distributed.get_rank() == 0:
        #     torch.distributed.barrier()  # Make sure only the first process in distributed training will download model

不同步问题解决方案

其实最省事省力的方法就是retry, 参考 pypi

from retrying import retry
@retry(stop_max_attempt_number=5)
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐