Skip to content

Commit

Permalink
[loops] Reset reference to dataloader iterator on run end
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthsub committed Sep 9, 2021
1 parent 41ba639 commit cd766b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions pytorch_lightning/loops/epoch/evaluation_epoch_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def on_run_end(self) -> EPOCH_OUTPUT:
outputs = self.outputs
# free memory
self.outputs = []
self.dataloader_iter = None
return outputs

def evaluation_step(self, batch: Any, batch_idx: int, dataloader_idx: int) -> Optional[STEP_OUTPUT]:
Expand Down
2 changes: 2 additions & 0 deletions pytorch_lightning/loops/epoch/training_epoch_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ def on_run_end(self) -> None:
if self._num_training_batches_reached(self.is_last_batch):
self.update_lr_schedulers("epoch", update_plateau_schedulers=True)

self.dataloader_iter = None

def teardown(self) -> None:
self._results.cpu()
self.batch_loop.teardown()
Expand Down

0 comments on commit cd766b8

Please sign in to comment.