diff --git a/pytorch_lightning/models/trainer.py b/pytorch_lightning/models/trainer.py index 40767410..605f2c78 100644 --- a/pytorch_lightning/models/trainer.py +++ b/pytorch_lightning/models/trainer.py @@ -259,6 +259,11 @@ class Trainer(TrainerIO): last_epoch = -1 last_ckpt_name = None + # do nothing if there's not dir or callback + no_ckpt_callback = self.checkpoint_callback is None + if no_ckpt_callback or not os.path.exists(self.checkpoint_callback.filepath): + return + # find last epoch checkpoints = os.listdir(self.checkpoint_callback.filepath) for name in checkpoints: diff --git a/tests/test_models.py b/tests/test_models.py index eeab97f0..c71d3023 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -26,6 +26,38 @@ np.random.seed(SEED) # ------------------------------------------------------------------------ # TESTS # ------------------------------------------------------------------------ +def test_simple_cpu(): + """ + Verify continue training session on CPU + :return: + """ + hparams = get_hparams() + model = LightningTestModel(hparams) + + save_dir = init_save_dir() + + # exp file to get meta + test_exp_version = 10 + exp = get_exp(False, version=test_exp_version) + exp.argparse(hparams) + exp.save() + + trainer_options = dict( + max_nb_epochs=1, + val_percent_check=0.1, + train_percent_check=0.1, + experiment=exp, + ) + + # fit model + trainer = Trainer(**trainer_options) + result = trainer.fit(model) + + # traning complete + assert result == 1, 'amp + ddp model failed to complete' + + clear_save_dir() + def test_amp_single_gpu(): """