Skip to content

Fix ray import error when both ROCR_VISIBLE_DEVICES and HIP_VISIBLE_DEVICES are set#53757

Merged
jjyao merged 3 commits intoray-project:masterfrom
2niuhe:rocm_env_fix
Jun 20, 2025
Merged

Fix ray import error when both ROCR_VISIBLE_DEVICES and HIP_VISIBLE_DEVICES are set#53757
jjyao merged 3 commits intoray-project:masterfrom
2niuhe:rocm_env_fix

Conversation

@2niuhe
Copy link
Copy Markdown
Contributor

@2niuhe 2niuhe commented Jun 12, 2025

Why are these changes needed?

When both ROCR_VISIBLE_DEVICES=0 and HIP_VISIBLE_DEVICES=0 are set (as default settings added to .bashrc during ROCm installation), importing ray in Python 3.11.12 results in a RuntimeError indicating that HIP_VISIBLE_DEVICES should be used instead of ROCR_VISIBLE_DEVICES.

Expected Behavior:
Ray should ignore ROCR_VISIBLE_DEVICES if HIP_VISIBLE_DEVICES is set

Related issue number

#53737

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

…EVICES are set

Signed-off-by: 2niuhe <carlton2tang@gmail.com>
@vickytsang
Copy link
Copy Markdown
Contributor

@2niuhe This looks good. The runtime error was added to mitigate an issue with Pytorch which has been resolved by pytorch/pytorch#144026.

cc: @jjyao @kevin85421

@kevin85421 kevin85421 added the go add ONLY when ready to merge, run all tests label Jun 18, 2025
@kevin85421
Copy link
Copy Markdown
Member

@2niuhe please ping me when all CI tests pass.

@jjyao
Copy link
Copy Markdown
Contributor

jjyao commented Jun 18, 2025

@vickytsang for review

@2niuhe
Copy link
Copy Markdown
Contributor Author

2niuhe commented Jun 19, 2025

@kevin85421 All CI tests have passed. Please review.

2niuhe added 2 commits June 20, 2025 12:42
Signed-off-by: niu_he <carlton2tang@gmail.com>
Signed-off-by: niu_he <carlton2tang@gmail.com>
@jjyao jjyao merged commit d1c665e into ray-project:master Jun 20, 2025
5 checks passed
minerharry pushed a commit to minerharry/ray that referenced this pull request Jun 27, 2025
…SIBLE_DEVICES are set (ray-project#53757)

Signed-off-by: 2niuhe <carlton2tang@gmail.com>
Signed-off-by: niu_he <carlton2tang@gmail.com>
elliot-barn pushed a commit that referenced this pull request Jul 2, 2025
…SIBLE_DEVICES are set (#53757)

Signed-off-by: 2niuhe <carlton2tang@gmail.com>
Signed-off-by: niu_he <carlton2tang@gmail.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants