Skip to content

Conversation

@godnight10061
Copy link
Contributor

@godnight10061 godnight10061 commented Dec 16, 2025

Problem

torchruntime.utils.get_installed_torch_platform() currently probes DirectML first. On Windows, users can have both:

  • torch-directml installed, and
  • a working torch build where torch.cuda.is_available() == True (e.g. after switching to ROCm/TheRock or CUDA wheels but leaving torch-directml installed)

In that scenario, torchruntime reports the installed backend as directml even though CUDA/ROCm is available. This can lead to incorrect device selection and confusing logs (see runew0lf/RuinedFooocus#285).

Fix

Prefer native Torch backends before DirectML:

  • Check torch.cuda (and torch.xpu) first
  • Keep DirectML as a fallback when CUDA/XPU are unavailable

Tests (TDD)

Added tests/test_torch_device_utils.py covering:

  • CUDA + DirectML available -> returns cuda
  • DirectML available, CUDA unavailable -> returns directml

Notes

This does not change the recommended platform returned by platform_detection.get_torch_platform() for AMD on Windows (still directml). It only fixes detection of what is already installed/available.

Fix get_installed_torch_platform() to prefer torch.cuda when both torch_directml and torch.cuda are available (common in Windows setups that keep torch-directml installed after switching to ROCm/CUDA builds).
@cmdr2 cmdr2 merged commit f1358b1 into easydiffusion:main Dec 19, 2025
2 checks passed
@cmdr2
Copy link
Contributor

cmdr2 commented Dec 19, 2025

Merged, thanks!

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