mirror of https://github.com/InternLM/InternLM
fix(os): fix FileNotFoundError in storage_manager (#455)
* use rank0 to makedirs * use try-except to handle file error * fix cipull/464/head
parent
4995060d84
commit
f77f376fd6
|
@ -662,8 +662,11 @@ class LocalClient(StorageClient):
|
||||||
def sync_upload_fileobj(fp: str, saved_obj=None, **kwargs):
|
def sync_upload_fileobj(fp: str, saved_obj=None, **kwargs):
|
||||||
assert saved_obj is not None
|
assert saved_obj is not None
|
||||||
fp_dirname = os.path.dirname(fp)
|
fp_dirname = os.path.dirname(fp)
|
||||||
if not os.path.exists(fp_dirname):
|
try:
|
||||||
os.makedirs(fp_dirname, exist_ok=True)
|
if not os.path.exists(fp_dirname):
|
||||||
|
os.makedirs(fp_dirname, exist_ok=True)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
torch.save(saved_obj, fp, **kwargs)
|
torch.save(saved_obj, fp, **kwargs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue