Fix issue #292 pytorch-lighting multi node store

This commit is contained in:
allegroai 2021-01-24 09:18:18 +02:00
parent 828af76ffe
commit 381ae21cef

View File

@ -104,10 +104,19 @@ class PatchPyTorchModelIO(PatchBaseModelIO):
@staticmethod
def _save(original_fn, obj, f, *args, **kwargs):
ret = original_fn(obj, f, *args, **kwargs)
# if there is no main task or this is a nested call
if not PatchPyTorchModelIO.__main_task:
return ret
# pytorch-lightning check if rank is zero
if hasattr(obj, 'is_global_zero'):
if not obj.is_global_zero:
return ret
elif hasattr(obj, 'trainer') and hasattr(obj.trainer, 'is_global_zero'):
if not obj.trainer.is_global_zero:
return ret
# noinspection PyBroadException
try:
if isinstance(f, six.string_types):