-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Support ddp_fork strategy with native AMP by attempting NVML-based CUDA availability assessment #14984
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
Merged
awaelchli
merged 15 commits into
Lightning-AI:master
from
speediedan:enable_ddp_fork_strategy_with_native_amp
Oct 5, 2022
Merged
Support ddp_fork strategy with native AMP by attempting NVML-based CUDA availability assessment #14984
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fe938c5
support DDP_FORK strategy with native AMP by attempting NVML-based CU…
speediedan f91d46c
update CHANGELOG
speediedan 5760519
narrow scope of RunIf NVML-based CUDA availability check to a new Run…
speediedan 18a99b5
clarify new runif condition, add skip_windows condition to new test
speediedan 9908f3f
add context manager that safely patches :func:`torch.cuda.is_availabl…
speediedan 3bc0117
update min_cuda_gpus RunIf condition for both PL and Lite, narrow sco…
speediedan dac8f68
restructure to avoid unnecessary None check
speediedan 4016b5d
remove unnecessary None assignment
speediedan 8441726
cleanup verbose documentation, revert `AMPTestModel` location, refine…
speediedan 6cc8e44
add missing yield
speediedan 3a4b0b9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] eb04abe
nit
carmocca b407bfe
Merge branch 'master' into enable_ddp_fork_strategy_with_native_amp
Borda 635d9bd
since we're not using my original ddp_fork full strategy test anymore…
speediedan bba3e82
looks like an unrequired import got added to native_amp sometime in t…
speediedan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Copyright The PyTorch Lightning team. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import multiprocessing | ||
|
|
||
| import torch | ||
|
|
||
| from pytorch_lightning.plugins import NativeMixedPrecisionPlugin | ||
| from tests_pytorch.helpers.runif import RunIf | ||
|
|
||
|
|
||
| # needs to be standalone to avoid other processes initializing CUDA | ||
| @RunIf(min_cuda_gpus=1, skip_windows=True, standalone=True) | ||
| def test_amp_gpus_ddp_fork(): | ||
| """Ensure the use of native AMP with `ddp_fork` (or associated alias strategies) does not generate CUDA | ||
| initialization errors.""" | ||
| _ = NativeMixedPrecisionPlugin(precision=16, device="cuda") | ||
| with multiprocessing.get_context("fork").Pool(1) as pool: | ||
| in_bad_fork = pool.apply(torch.cuda._is_in_bad_fork) | ||
| assert not in_bad_fork | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.