clear memory cache before train starts (#418)

* clear memory cache before train starts

* clear memory cache before train starts
This commit is contained in:
William Falcon 2019-10-23 11:41:00 -04:00 committed by GitHub
parent d955baa235
commit c6244594a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -447,6 +447,10 @@ class Trainer(TrainerIOMixin,
self.evaluate(model, self.get_val_dataloaders(), self.nb_sanity_val_steps, self.testing)
# clear cache before training
if self.on_gpu:
torch.cuda.empty_cache()
# CORE TRAINING LOOP
self.train()

View File

@ -327,7 +327,8 @@ def test_cpu_restore_training():
# set the epoch start hook so we can predict before the model does the full training
def assert_good_acc():
assert trainer.current_epoch == real_global_epoch and trainer.current_epoch > 0
assert trainer.current_epoch > 0
assert trainer.current_epoch == real_global_epoch
# if model and state loaded correctly, predictions will be good even though we
# haven't trained with the new loaded model