Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resuming from specific checkpoint #516

Merged
merged 7 commits into from
Nov 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pytorch_lightning/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def __init__(self,
weights_save_path=None,
amp_level='O1',
nb_sanity_val_steps=5,
truncated_bptt_steps=None):
truncated_bptt_steps=None,
resume_from_checkpoint=None):
"""

:param logger: Logger for experiment tracking
Expand Down Expand Up @@ -140,6 +141,7 @@ def __init__(self,
self.nb_sanity_val_steps = nb_sanity_val_steps
self.print_nan_grads = print_nan_grads
self.truncated_bptt_steps = truncated_bptt_steps
self.resume_from_checkpoint = resume_from_checkpoint
self.shown_warnings = set()

self.fast_dev_run = fast_dev_run
Expand Down
7 changes: 5 additions & 2 deletions pytorch_lightning/trainer/trainer_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ def restore_weights(self, model):
torch.cuda.empty_cache()

if not did_restore_hpc_weights:
# restore weights if same exp version
self.restore_state_if_checkpoint_exists(model)
if self.resume_from_checkpoint is not None:
self.restore(self.resume_from_checkpoint, on_gpu=self.on_gpu)
else:
# restore weights if same exp version
self.restore_state_if_checkpoint_exists(model)

# wait for all models to restore weights
if self.use_ddp or self.use_ddp2:
Expand Down