Skip to content

Commit

Permalink
Fixes CPU and hanging GPU crash (#2118)
Browse files Browse the repository at this point in the history
* training batch clean up

* training batch clean up

* training batch clean up
  • Loading branch information
williamFalcon authored and justusschock committed Jun 29, 2020
1 parent 163850c commit ee05ee1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pytorch_lightning/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ def run_pretrain_routine(self, model: LightningModule):
self.early_stop_callback._validate_condition_metric(callback_metrics)

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

0 comments on commit ee05ee1

Please sign in to comment.