Skip to content

Commit

Permalink
Fix weird docker error (#2581)
Browse files Browse the repository at this point in the history
(cherry picked from commit b0da59e)
  • Loading branch information
SkafteNicki authored and Borda committed Aug 2, 2024
1 parent b862497 commit cd2cbc0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/torchmetrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def __init__(
# see (https://github.com/pytorch/pytorch/blob/3e6bb5233f9ca2c5aa55d9cda22a7ee85439aa6e/
# torch/nn/modules/module.py#L227)
torch._C._log_api_usage_once(f"torchmetrics.metric.{self.__class__.__name__}")

# magic patch for `RuntimeError: DataLoader worker (pid(s) 104) exited unexpectedly`
self._TORCH_GREATER_EQUAL_2_1 = bool(_TORCH_GREATER_EQUAL_2_1)
self._device = torch.device("cpu")
self._dtype = torch.get_default_dtype()

Expand Down Expand Up @@ -441,7 +442,7 @@ def _sync_dist(self, dist_sync_fn: Callable = gather_all_tensors, process_group:

# cornor case in distributed settings where a rank have not received any data, create empty to concatenate
if (
_TORCH_GREATER_EQUAL_2_1
self._TORCH_GREATER_EQUAL_2_1
and reduction_fn == dim_zero_cat
and isinstance(input_dict[attr], list)
and len(input_dict[attr]) == 0
Expand Down

0 comments on commit cd2cbc0

Please sign in to comment.