-
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
Does Trainer(devices=1)
use all CPUs?
#19595
Comments
@MaximilienLC Do you mean this? trainer = Trainer(
accelerator="cpu",
devices=[1, 3],
)
This is correct. It does not make sense to select device indices on a CPU. Device indices are meant for accelerators like CUDA GPUs or TPUs. If you select |
If there is documentation that contradicts this, please point me to it so we can update it. Thanks! |
I guess this section could add that info for CPU. So you mean |
Yes PyTorch will use all CPUs if it can parallelize the operation accordingly. |
Trainer
argument devices
will always raise an Exception with arguments accelerator=cpu
and devices: list[int]
Trainer(devices=1)
use all CPUs?
I agree that this should not throw an exception assuming the current documentation is correct. For example, the device could come from an environment variable trainer = Trainer(
accelerator=os.environ.get("DEVICE", "cpu"),
devices=-1, # use all devices
) So when deploying the code to different machines, it would break for CPU. Maybe a warning would be more adequate to notify the user that something is not optimally configured. Would |
Hi! Would like to work on this one. @awaelchli, wanted to clarify, what is more logical here: change the exception in the case |
Humbly I think the solution should be to remove List[int] as an input type for cpu accelerator, @awaelchli please review this PR! |
Bug description
pytorch-lightning/src/lightning/fabric/accelerators/cpu.py
Line 75 in 3740546
cpu_cores
being a list of integers will always raise an exception, which shouldn't according to the Trainer documentation/this function signatureWhat version are you seeing the problem on?
master
How to reproduce the bug
No response
Error messages and logs
Environment
Current environment
More info
No response
cc @Borda
The text was updated successfully, but these errors were encountered: