You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Vulkan fallback for ROCm-unsupported AMD cards in stable-diffusion.cpp #13666
On AMD GPUs that are too old for modern ROCm (e.g. Vega 10), Unsloth falls back to
CPU-only PyTorch because there's no ROCm wheel available for these architectures. As a result, torch.cuda.is_available() returns False, leading to resolve_diffusion_device_target() falling back to "cpu" in studio/backend/core/inference/diffusion_device.py.
However, these cards can run Vulkan perfectly fine via RADV/Mesa. There's currently no way to
tell Unsloth to install the Vulkan sd.cpp binary on such systems.
Current workaround
Minimal edit to studio/backend/core/inference/diffusion_engine_router.py → image_install_accelerator():
defimage_install_accelerator(backend: str) ->str:
"""The sd.cpp build the IMAGE engine wants..."""# ``UNSLOTH_DIFFUSION_SD_CPP_FORCE_VULKAN=1`` forces Vulkan regardless of torchdetection,
# for AMD cards (Vega 10) that lack a ROCm wheel and fall back to CPU-onlytorch.
force_vulkan=os.environ.get("UNSLOTH_DIFFUSION_SD_CPP_FORCE_VULKAN",
"").strip().lower()
ifforce_vulkanin ("1", "true", "yes", "on"):
return"vulkan"off_torch=off_torch_sd_cpp_device(backend)
returnoff_torch.acceleratorifoff_torchisnotNoneelse_install_accelerator_for(backend)
Then add UNSLOTH_DIFFUSION_SD_CPP_FORCE_VULKAN=1 as environment variable.
There's probably a much more elegant way to do this, mirroring how Llama.cpp inference falls back to Vulkan on the same card by default.
Activity
Studio: run native image generation on Vulkan when torch is CPU-only …
lukegjohnson commentedon Oct 14, 2026
Great stuff, thanks!
Studio sd.cpp: a CPU torch on a 16 GB Vulkan card stops forcing MiniM…