From b8d9171d891c69e5908fd47e1c830860e6a73642 Mon Sep 17 00:00:00 2001 From: htliu Date: Wed, 2 Sep 2020 12:21:18 +0800 Subject: [PATCH] Fix: gather_all_tensors cross GPUs in metrics --- pytorch_lightning/metrics/converters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytorch_lightning/metrics/converters.py b/pytorch_lightning/metrics/converters.py index a41a621c905da8..2bfe8fa28a61c2 100644 --- a/pytorch_lightning/metrics/converters.py +++ b/pytorch_lightning/metrics/converters.py @@ -301,7 +301,7 @@ def gather_all_tensors_if_available(result: Union[torch.Tensor], world_size = torch.distributed.get_world_size(group) - gathered_result = world_size * [torch.zeros_like(result)] + gathered_result = [torch.zeros_like(result) for _ in range(world_size)] # sync and broadcast all torch.distributed.barrier(group=group)