Skip to content

Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.

fix: device fallback handles cuda:N format correctly

游雁2a770be16518
diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.py
index 25f3b1f99..195fe336a 100644
--- a/funasr/auto/auto_model.py
+++ b/funasr/auto/auto_model.py
@@ -208,10 +208,10 @@ class AutoModel:
device = kwargs.get("device", "cuda")
if (
- (device == "cuda" and not torch.cuda.is_available())
- or (device == "xpu" and not torch.xpu.is_available())
- or (device == "mps" and not torch.backends.mps.is_available())
- or (device == "npu" and not is_npu_available())
+ (device.startswith("cuda") and not torch.cuda.is_available())
+ or (device.startswith("xpu") and not torch.xpu.is_available())
+ or (device.startswith("mps") and not torch.backends.mps.is_available())
+ or (device.startswith("npu") and not is_npu_available())
or kwargs.get("ngpu", 1) == 0
):
device = "cpu"