-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fabric: Enable auto
for devices
and accelerator
cli` arguments
#20913
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #20913 +/- ##
=======================================
- Coverage 87% 87% -0%
=======================================
Files 268 268
Lines 23442 23456 +14
=======================================
+ Hits 20394 20402 +8
- Misses 3048 3054 +6 |
src/lightning/fabric/cli.py
Outdated
@@ -187,6 +187,19 @@ def _set_env_variables(args: Namespace) -> None: | |||
|
|||
def _get_num_processes(accelerator: str, devices: str) -> int: | |||
"""Parse the `devices` argument to determine how many processes need to be launched on the current machine.""" | |||
if accelerator == "auto" or accelerator is None: |
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.
lets not duplicate the logic and use already written functions like:
pytorch-lightning/src/lightning/pytorch/trainer/connectors/accelerator_connector.py
Line 333 in c85660c
def _choose_auto_accelerator() -> str: |
_SUPPORTED_ACCELERATORS = ("cpu", "gpu", "cuda", "mps", "tpu", "auto") | ||
|
||
|
||
def _choose_auto_accelerator() -> str: |
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.
so why do we have now the same function?
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.
I tried to import from
pytorch-lightning/src/lightning/pytorch/trainer/connectors/accelerator_connector.py
Line 333 in c85660c
def _choose_auto_accelerator() -> str: |
But there were some dependencies errors, one for
torchmetrics
on some runners.
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.
What does this PR do?
Fixes #20451
This PR adds support for the
auto
variable foraccelerator
anddevices
in the Fabric CLI.When
auto
is passed to--accelerator
we now detect whether the machine has eithermps
,cuda
, orcpu
and dynamically runs on the available device, this is the same case when no accelerator is specified.For
auto
in the--devices
argument the devices default to1
as specified in the docstring of the argument herepytorch-lightning/src/lightning/fabric/cli.py
Line 80 in c03660a
No breaking changes were introduced.
Before submitting
PR review
Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
Reviewer checklist
📚 Documentation preview 📚: https://pytorch-lightning--20913.org.readthedocs.build/en/20913/