-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add cuda_device_count_stateless
#5473
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b89b8e3
Add `get_num_gpus_available_isolated`
Yard1 babcfe4
Apply suggestions from code review
Yard1 bc7afc3
Lint
Yard1 dfddcae
Lint
Yard1 3c7690e
Tweak
Yard1 2684305
Tweak
Yard1 85a24ef
Add comment
Yard1 a507a11
Replace subprocess with direct call
Yard1 d13dcc0
Tweak docstring
Yard1 6dc50f0
Review feedback
Yard1 fdadaf0
Clarify
Yard1 bf43ffb
Add test
Yard1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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"] | ||
mgoin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.