[bug fix] CUDA error: invalid device ordinal when CUDA_VISIBLE_DEVICES start id is not equal to 0#116
Merged
zhuzilin merged 4 commits intoTHUDM:mainfrom Aug 11, 2025
Merged
Conversation
3bd94ff to
18e12e9
Compare
8 tasks
This was referenced Aug 13, 2025
fy1214
pushed a commit
to fy1214/slime
that referenced
this pull request
Aug 13, 2025
…S start id is not equal to 0 (THUDM#116) * fix on train side * fix on rollout side * revert noset cvd on rollout side * add notice in --rollout-num-gpus-per-node
rysaya
pushed a commit
to rysaya/slime
that referenced
this pull request
Aug 15, 2025
…S start id is not equal to 0 (THUDM#116) * fix on train side * fix on rollout side * revert noset cvd on rollout side * add notice in --rollout-num-gpus-per-node
llltttwww
pushed a commit
to llltttwww/slime
that referenced
this pull request
Nov 30, 2025
…S start id is not equal to 0 (THUDM#116) * fix on train side * fix on rollout side * revert noset cvd on rollout side * add notice in --rollout-num-gpus-per-node
yueming-yuan
pushed a commit
to yueming-yuan/slime
that referenced
this pull request
Dec 29, 2025
Yangruipis
pushed a commit
to redai-infra/slime
that referenced
this pull request
Feb 28, 2026
…S start id is not equal to 0 (THUDM#116) * fix on train side * fix on rollout side * revert noset cvd on rollout side * add notice in --rollout-num-gpus-per-node
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
NOTE: This PR may have better implementation after #54928 in ray is merged.
The bug should be devided into two problems:
And the expected behavior is: We can simply assign the physical GPU id by setting
CUDA_VISIBLE_DEVICESbefore ray start and ray job submit.On train side:
LOCAL_RANKinTrainRayActorshould be logical gpu id rather than physical gpu id. Thentorch.cuda.set_devicewill works correctly.On rollout side:
The GPU allocated for RolloutRayActor (set to 0.2) is just a placeholder. In the original behavior,
SglangEngineclass clear theCUDA_VISIBLE_DEVICESsettings, and allocate GPU for sglang starting from physical GPU 0 continously. This behavior leads to the two problems.In this PR, we set
RAY_EXPERIMENTAL_NOSET_CUDA_VISIBLE_DEVICESin RolloutRayActor to avoid ray from modifyingCUDA_VISIBLE_DEVICES. So SGLang server can be launched using externalCUDA_VISIBLE_DEVICES, which resolve the two problems.Test result:
After logging
nvidia-smievery 3 seconds, there is no GPU utilization out of CUDA_VISIBLE_DEVICES. We can assume the modification is correct.