Skip to content

revert select_device#9559

Merged
Jintao-Huang merged 5 commits into
modelscope:mainfrom
Jintao-Huang:revert_select_device
Jun 15, 2026
Merged

revert select_device#9559
Jintao-Huang merged 5 commits into
modelscope:mainfrom
Jintao-Huang:revert_select_device

Conversation

@Jintao-Huang

Copy link
Copy Markdown
Collaborator
截屏2026-06-15 14 11 08

Pre-initializing CUDA causes environment variables to become ineffective.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the custom select_device utility with direct assignments to os.environ['CUDA_VISIBLE_DEVICES'] across numerous test files. The review feedback identifies several key improvement opportunities: first, CUDA_VISIBLE_DEVICES should be set before importing torch to avoid premature CUDA initialization; second, environment variables should be set at the module level rather than inside if __name__ == '__main__': blocks so they are properly configured when run via test runners like pytest; and third, using os.environ.setdefault is recommended to allow command-line overrides in local or CI/CD environments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread tests/infer/test_infer.py
Comment thread tests/infer/test_logprobs.py
Comment thread tests/llm/test_run.py
Comment thread tests/llm/test_ollama_export.py
Comment thread tests/test_align/test_template/test_llm.py
@Jintao-Huang Jintao-Huang merged commit 37d9c87 into modelscope:main Jun 15, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants