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

move device-specific teardown logic from training loop to accelerator #5973

Merged
merged 9 commits into from
Feb 15, 2021

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Feb 14, 2021

What does this PR do?

Follow up to #5743

on_train_end device-specific teardown should be handled by accelerator.
Makes training loop device agnostic

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified
  • Check that target branch and milestone match!

Did you have fun?

Make sure you had fun coding 🙃

@codecov
Copy link

codecov bot commented Feb 14, 2021

Codecov Report

Merging #5973 (b6e2fbd) into master (ae4dca9) will decrease coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #5973   +/-   ##
======================================
- Coverage      90%     90%   -0%     
======================================
  Files         170     170           
  Lines       11789   11786    -3     
======================================
- Hits        10669   10637   -32     
- Misses       1120    1149   +29     

@Borda Borda added this to the 1.2 milestone Feb 15, 2021
@Borda Borda enabled auto-merge (squash) February 15, 2021 07:53
@Borda Borda added the ready PRs ready to be merged label Feb 15, 2021
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@@ -27,6 +27,7 @@ def on_train_start(self):

def on_train_end(self):
# clean up memory
self.model.cpu()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do this for TPU too ?

self.trainer.accelerator_backend.on_train_end()

# clear mem
if self.trainer._device_type == DeviceType.GPU:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleaning !

@Borda Borda merged commit aa60c08 into master Feb 15, 2021
@Borda Borda deleted the refactor/teardown branch February 15, 2021 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PRs ready to be merged refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants