Skip to content

Commit ee05ee1

Browse files
williamFalconjustusschock
authored andcommitted
Fixes CPU and hanging GPU crash (#2118)
* training batch clean up * training batch clean up * training batch clean up
1 parent 163850c commit ee05ee1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pytorch_lightning/trainer/trainer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ def run_pretrain_routine(self, model: LightningModule):
10331033
self.early_stop_callback._validate_condition_metric(callback_metrics)
10341034

10351035
# clear cache before training
1036-
if self.on_gpu:
1036+
if self.on_gpu and self.root_gpu is not None:
10371037
# use context because of:
10381038
# https://discuss.pytorch.org/t/out-of-memory-when-i-use-torch-cuda-empty-cache/57898
10391039
with torch.cuda.device(f'cuda:{self.root_gpu}'):

0 commit comments

Comments
 (0)