Skip to content

Commit a8433bd

Browse files
committed
cheat
1 parent 78438cd commit a8433bd

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

pytorch_lightning/trainer/trainer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ def _run_evaluation(self) -> _EVALUATE_OUTPUT:
992992
del batch
993993
import gc
994994
gc.collect()
995+
torch.cuda.empty_cache()
995996

996997
# log batch metrics
997998
self.logger_connector.update_eval_step_metrics()
@@ -1102,6 +1103,7 @@ def _run_predict(self) -> Optional[_PREDICT_OUTPUT]:
11021103
del batch
11031104
import gc
11041105
gc.collect()
1106+
torch.cuda.empty_cache()
11051107

11061108
# call hook
11071109
results = self.predict_loop.on_predict_epoch_end()

pytorch_lightning/trainer/training_loop.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ def run_training_epoch(self):
485485
del batch
486486
import gc
487487
gc.collect()
488+
torch.cuda.empty_cache()
488489

489490
# -----------------------------------------
490491
# SAVE METRICS TO LOGGERS AND PROGRESS_BAR

0 commit comments

Comments
 (0)