-
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
Avoid fallback on CPU if no devices are provided #12410
Conversation
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.
Could you update the docs as well?
For example: https://pytorch-lightning.readthedocs.io/en/latest/accelerators/gpu.html#select-gpu-devices
Hi @rohitgr7, it makes sense to me However, currently Even |
That's ok, it is documented here.
Agreed, this is probably not intended and should be changed. |
@@ -506,6 +506,15 @@ def test_accelerator_cpu(_): | |||
trainer = Trainer(accelerator="cpu", gpus=1) | |||
|
|||
|
|||
@mock.patch("torch.cuda.is_available", return_value=False) |
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.
Here, we assumed the accelerator is not available. What if it's available and user pass devices="0"/0/ []]
?
It leads to such errors
self._parallel_devices = self.accelerator.get_parallel_devices(self._devices_flag)
File "/home/jovyan/pytorch-lightning/pytorch_lightning/accelerators/gpu.py", line 82, in get_parallel_devices
return [torch.device("cuda", i) for i in devices]
TypeError: 'NoneType' object is not iterable
It is addressed in #12633
What does this PR do?
Addresses: #12160 (comment)
Does your PR introduce any breaking changes? If yes, please list them.
Before submitting
PR review
Anyone in the community is welcome to review the PR.
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 🙃
cc @Borda @justusschock @kaushikb11 @awaelchli @ninginthecloud @akihironitta @rohitgr7