Fix GPU device options missing from module/device selectors#76
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 435456aed3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if torch.cuda.is_available() or cuda_count > 0: | ||
| DEFAULT_DEVICE = 'cuda' | ||
| _append_unique_device('cuda') |
There was a problem hiding this comment.
Require CUDA availability before choosing it as default
The new condition torch.cuda.is_available() or cuda_count > 0 can set DEFAULT_DEVICE to cuda even when PyTorch reports CUDA is not usable in the current process. This happens in partially broken CUDA installs (e.g., driver/runtime init failures) where device enumeration can still return a positive count; the app will then default to CUDA and later fail on model load or cache ops instead of safely staying on CPU. The previous behavior only selected CUDA when is_available() was true, so this introduces a regression in startup/device-selection reliability.
Useful? React with 👍 / 👎.
Motivation
Defaultandcpubecause runtime device discovery was fragile and didn’t expose GPU device options inAVAILABLE_DEVICES.Description
modules/base.pyby introducing_append_unique_deviceand buildingAVAILABLE_DEVICESfrom a single source of truth.torch.cuda.is_available()andtorch.cuda.device_count()and addingcudaplus indexed entries (cuda:0,cuda:1, ...) when present.DEVICE_SELECTOR()continues to read fromAVAILABLE_DEVICES, so UI selectors and module defaults automatically pick up discovered devices.Testing
python -m compileall -f -q modules/base.pyand it completed successfully.python - <<'PY' ... import modules.base as b ... PYthat printedDEFAULT_DEVICE,AVAILABLE_DEVICES, andDEVICE_SELECTOR(); the script ran successfully and showed CPU-only results in this environment (expected because no CUDA devices are exposed here).Codex Task