Handle edge case for `find_usable_cuda_devices(0)` (#18722)
This commit is contained in:
parent
379ed8c66e
commit
87dff9928e
|
@ -221,6 +221,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
|
|||
- Fixed redundant input-type casting in FSDP precision ([#18630](https://github.com/Lightning-AI/lightning/pull/18630))
|
||||
|
||||
|
||||
- Fixed an issue with `find_usable_cuda_devices(0)` incorrectly returning a list of devices ([#18722](https://github.com/Lightning-AI/lightning/pull/18722))
|
||||
|
||||
|
||||
## [2.0.9] - 2023-09-14
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -90,6 +90,8 @@ def find_usable_cuda_devices(num_devices: int = -1) -> List[int]:
|
|||
both processes determine that the device is unoccupied, leading into one of them crashing later on.
|
||||
|
||||
"""
|
||||
if num_devices == 0:
|
||||
return []
|
||||
visible_devices = _get_all_visible_cuda_devices()
|
||||
if not visible_devices:
|
||||
raise ValueError(
|
||||
|
|
|
@ -157,3 +157,6 @@ def test_find_usable_cuda_devices_error_handling():
|
|||
"lightning.fabric.accelerators.cuda.torch.tensor"
|
||||
):
|
||||
assert find_usable_cuda_devices(-1) == [0, 1, 2, 3, 4]
|
||||
|
||||
# Edge case
|
||||
assert find_usable_cuda_devices(0) == []
|
||||
|
|
Loading…
Reference in New Issue