-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[bug] Set device on LightningModule after fitting #7188
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7188 +/- ##
=======================================
- Coverage 92% 87% -5%
=======================================
Files 197 197
Lines 12622 12667 +45
=======================================
- Hits 11631 11000 -631
- Misses 991 1667 +676 |
Hello @tchaton! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-04-23 13:45:29 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Minor nit: perhaps the test could have been integrated in an existing test that just runs fit, in one of the tests/models/test_gpu tests perhaps.
but minor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 😃
Co-authored-by: Carlos Mocholí <[email protected]>
…g/pytorch-lightning into device_placement
@@ -47,9 +47,10 @@ def on_train_start(self) -> None: | |||
with torch.cuda.device(self.root_device): | |||
torch.cuda.empty_cache() | |||
|
|||
def on_train_end(self) -> None: | |||
def teardown(self) -> None: | |||
self.lightning_module.cpu() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SeanNaren for sharded training, do we need to move both self.model and self.lightning_module? Could this lead to errors like what we saw for eval/train with SDP earlier?
What does this PR do?
This PR resolve a bug with device placement.
When running with gpu accelerator, the model was correctly put on cpu but the device was still set to cuda.
Before submitting
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:
Did you have fun?
Make sure you had fun coding 🙃