Skip to content

Commit 3f7d0ed

Browse files
committed
Move predictions to CPU before accumulating
1 parent 6f3cb1a commit 3f7d0ed

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pytorch_lightning/loops/epoch/prediction_epoch_loop.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from pytorch_lightning.loops.base import Loop
77
from pytorch_lightning.overrides.distributed import IndexBatchSamplerWrapper
88
from pytorch_lightning.trainer.progress import Progress
9+
from pytorch_lightning.utilities.apply_func import move_data_to_device
910
from pytorch_lightning.utilities.warnings import WarningCache
1011

1112

@@ -140,7 +141,7 @@ def _predict_step(self, batch: Any, batch_idx: int, dataloader_idx: int) -> None
140141
self.batch_progress.increment_completed()
141142

142143
if self.should_store_predictions:
143-
self.predictions.append(predictions)
144+
self.predictions.append(move_data_to_device(predictions, "cpu"))
144145

145146
def _build_kwargs(self, batch: Any, batch_idx: int, dataloader_idx: int) -> Dict[str, Any]:
146147
"""

0 commit comments

Comments
 (0)