-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
cuda_device_count_stateless
(#5473)
- Loading branch information
Showing
8 changed files
with
79 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 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 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,31 @@ | ||
import os | ||
|
||
import ray | ||
|
||
from vllm.utils import cuda_device_count_stateless | ||
|
||
|
||
@ray.remote | ||
class _CUDADeviceCountStatelessTestActor(): | ||
|
||
def get_count(self): | ||
return cuda_device_count_stateless() | ||
|
||
def set_cuda_visible_devices(self, cuda_visible_devices: str): | ||
os.environ["CUDA_VISIBLE_DEVICES"] = cuda_visible_devices | ||
|
||
def get_cuda_visible_devices(self): | ||
return os.environ["CUDA_VISIBLE_DEVICES"] | ||
|
||
|
||
def test_cuda_device_count_stateless(): | ||
"""Test that cuda_device_count_stateless changes return value if | ||
CUDA_VISIBLE_DEVICES is changed.""" | ||
|
||
actor = _CUDADeviceCountStatelessTestActor.options(num_gpus=2).remote() | ||
assert ray.get(actor.get_cuda_visible_devices.remote()) == "0,1" | ||
assert ray.get(actor.get_count.remote()) == 2 | ||
ray.get(actor.set_cuda_visible_devices.remote("0")) | ||
assert ray.get(actor.get_count.remote()) == 1 | ||
ray.get(actor.set_cuda_visible_devices.remote("")) | ||
assert ray.get(actor.get_count.remote()) == 0 |
This file contains 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 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 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 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 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