Skip to content

Commit 0d09d71

Browse files
committed
Fix hang on rank zero only
1 parent 778d844 commit 0d09d71

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pytorch_lightning/core/lightning.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def log(
303303
add_dataloader_idx: bool = True,
304304
batch_size: Optional[int] = None,
305305
metric_attribute: Optional[str] = None,
306-
rank_zero_only: Optional[bool] = None,
306+
rank_zero_only: bool = False,
307307
) -> None:
308308
"""Log a key, value pair.
309309
@@ -441,7 +441,7 @@ def log_dict(
441441
sync_dist_group: Optional[Any] = None,
442442
add_dataloader_idx: bool = True,
443443
batch_size: Optional[int] = None,
444-
rank_zero_only: Optional[bool] = None,
444+
rank_zero_only: bool = False,
445445
) -> None:
446446
"""Log a dictionary of values at once.
447447

pytorch_lightning/trainer/connectors/logger_connector/result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,8 @@ def cpu(self) -> "ResultCollection":
616616

617617
def sync(self) -> None:
618618
for result_metric in self.result_metrics:
619-
if result_metric.is_tensor:
620-
result_metric.sync()
619+
if result_metric.is_tensor and not result_metric._is_synced:
620+
result_metric.sync(should_sync=not result_metric.meta.sync.rank_zero_only)
621621

622622
def unsync(self) -> None:
623623
for result_metric in self.result_metrics:

0 commit comments

Comments
 (0)