-
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
Fix DPP + SyncBN #6838
Fix DPP + SyncBN #6838
Conversation
Ensure that model is already on correct GPU before applying SyncBN conversion
Codecov Report
@@ Coverage Diff @@
## master #6838 +/- ##
=======================================
- Coverage 91% 87% -5%
=======================================
Files 192 192
Lines 12191 12191
=======================================
- Hits 11145 10595 -550
- Misses 1046 1596 +550 |
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.
looks like that's the correct thing to do.
can you apply the same to ddp_spawn.py
?
Greetings! Thanks for quick response. Added same changes to ddp_spawn in my last commit. |
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 ! Thanks for this catch !
# move the model to the correct device | ||
self.model_to_device() | ||
|
||
if self.sync_batchnorm: |
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.
if self.sync_batchnorm: | |
# `sync BatchNorm` requires a model on `cuda` device | |
if self.sync_batchnorm: |
# move the model to the correct device | ||
self.model_to_device() | ||
|
||
if self.sync_batchnorm: |
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.
if self.sync_batchnorm: | |
# `sync BatchNorm` requires a model on `cuda` device | |
if self.sync_batchnorm: |
* Fix DPP + SyncBN Ensure that model is already on correct GPU before applying SyncBN conversion * Fix order of SyncBN for ddp_spawn
* update readme by v1.2.x (#6728) * [bugfix] Add support for omegaconf and tpu (#6741) * fix_hydra * update changelog Co-authored-by: Your Name <[email protected]> * [docs] Update Bolts link (#6743) * Update Bolts link * Update Bolts link * formt Co-authored-by: Jirka Borovec <[email protected]> * Update logic for checking TPUs availability (#6767) * Update logic for checking TPUs availability * fix flake8 * add fix * resolve bug (#6781) * Fix validation progress counter with check_val_every_n_epoch > 1 (#5952) Co-authored-by: rohitgr7 <[email protected]> Co-authored-by: Carlos Mocholí <[email protected]> * Remove extinct parameters from lightning_module.rst (#6801) Fixes #6800 * Update TPU docs for installation (#6794) * fix boolean check on iterable dataset when len not defined (#6828) * fix iterable dataset len check * update predict and validate * add validate to test * add changelog * add predict * Sanitize `None` params during pruning (#6836) * sanitize none params during pruning * amend * Fix `unfreeze_and_add_param_group` expects `modules` rather than `module` (#6822) * Enforce an epoch scheduler interval when using SWA (#6588) Co-authored-by: Carlos Mocholi <[email protected]> * Fix DPP + SyncBN (#6838) * Fix DPP + SyncBN Ensure that model is already on correct GPU before applying SyncBN conversion * Fix order of SyncBN for ddp_spawn * [Fix] TPU Training Type Plugin (#6816) * Fix support for symlink save_dir in TensorBoardLogger (#6730) * Add test for symlink support and initial fix * Respond to comment and add docstring * Update CHANGELOG.md * Simplify * Update pytorch_lightning/utilities/cloud_io.py Co-authored-by: Carlos Mocholí <[email protected]> * Make `LightningLocalFileSystem` protected Co-authored-by: Carlos Mocholí <[email protected]> * Fixed missing arguments in `lr_find` call (#6784) There seem to be 3 arguments missing in the `lr_find` call in the tunining.py file. * Update Changelog & version * Fix TPU tests for checkpoint Skip advanced profiler for torch > 1.8 Skip pytorch profiler for torch > 1.8 Fix save checkpoint logic for TPUs Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: thomas chaton <[email protected]> Co-authored-by: Your Name <[email protected]> Co-authored-by: Akihiro Nitta <[email protected]> Co-authored-by: Yuan-Hang Zhang <[email protected]> Co-authored-by: rohitgr7 <[email protected]> Co-authored-by: Carlos Mocholí <[email protected]> Co-authored-by: Elizaveta Logacheva <[email protected]> Co-authored-by: Adrian Wälchli <[email protected]> Co-authored-by: Karthik Prasad <[email protected]> Co-authored-by: Sadiq Jaffer <[email protected]> Co-authored-by: Michael Baumgartner <[email protected]> Co-authored-by: Eugene Khvedchenya <[email protected]> Co-authored-by: Ethan Harris <[email protected]> Co-authored-by: Tharindu Hasthika <[email protected]>
* Fix DPP + SyncBN Ensure that model is already on correct GPU before applying SyncBN conversion * Fix order of SyncBN for ddp_spawn
What does this PR do?
This PR ensures that model is already on correct GPU before applying SyncBN conversion. According to PyTorch docs, SyncBN conversion should be applied to model that is already on target GPU. Not following this requirement will lead to hard-tracing errors of some BN layers kept on CPU.
Changing the order of
model_to_device
call seems to fix this issue without any side-effects to the rest of the code.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 🙃