use rank0 to makedirs

pull/455/head
gaoyang07 2023-10-26 22:48:38 +08:00
parent ad70e323eb
commit a862f503b6
1 changed files with 4 additions and 2 deletions

View File

@ -512,8 +512,10 @@ class LocalClient(StorageClient):
def sync_upload_fileobj(fp: str, saved_obj=None, **kwargs):
assert saved_obj is not None
fp_dirname = os.path.dirname(fp)
if not os.path.exists(fp_dirname):
os.makedirs(fp_dirname, exist_ok=True)
if gpc.get_global_rank() == 0:
if not os.path.exists(fp_dirname):
os.makedirs(fp_dirname, exist_ok=True)
dist.barrier()
torch.save(saved_obj, fp, **kwargs)
@staticmethod