Pytorch-lightning: support graceful training cleanup after Keyboard Interrupt

Created on 6 Feb 2020  路  7Comments  路  Source: PyTorchLightning/pytorch-lightning

馃殌 Feature

In the training loop, we should catch KeyboardInterrupt exceptions and enter a graceful termination (ie. run on_training_end, print profiler report, etc).

Motivation

Sometimes I'll train a model and just let it run until something interesting happens or my loss has converged. Exiting via "Ctrl + C" can be easier than waiting for "EarlyStopping" to trigger in some cases. However, I may still want certain things to occur (eg. printing out the profiler summary) after stopping training.

Salesforce's AWD-LSTM has an example of this feature implemented here.

Pitch

Figure out what actions we want to run after a KeyboardInterrupt. Then adjust the training loop to catch this exception and ensure the aforementioned actions still run afterwards.

enhancement help wanted

Most helpful comment

@lezwon Hmm yeah, that's not ideal. Do you mind creating a new issue (you can reference this one) with the problem and I can draft up a PR to address it?

All 7 comments

awesome, let's do it

@jeremyjordan can we get it into this release? :)

when鈥檚 the release? planning to get to it this weekend

feb 21

sure, shouldn't be a problem then :)

Hey guys, I am currently training a model on Sagemaker and have added a notebook shutdown code within the on_training_end method. There were times where I had to manually cancel my model training because something was wrong. However, If I do that, the notebook shuts down. Is there any way to make this feature optional? I don't want my notebook shutting down after a keyboard interrupt, only after successful training completion.

@lezwon Hmm yeah, that's not ideal. Do you mind creating a new issue (you can reference this one) with the problem and I can draft up a PR to address it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edenlightning picture edenlightning  路  3Comments

awaelchli picture awaelchli  路  3Comments

maxime-louis picture maxime-louis  路  3Comments

williamFalcon picture williamFalcon  路  3Comments

DavidRuhe picture DavidRuhe  路  3Comments