invoke-ai/InvokeAI · error · ValueError

generation_devices requested '{device_str}', but no XPU devi

Error message

generation_devices requested '{device_str}', but no XPU device is available.

What it means

get_generation_devices validates XPU devices analogously to CUDA: an explicitly requested xpu device is rejected immediately if Intel XPU support is not available (_xpu_is_available() is false — no torch.xpu device / IPEX runtime).

Source

Thrown at invokeai/backend/util/devices.py:305

        devices: list[torch.device] = []
        seen: set[str] = set()
        for device_str in device_strs:
            device = cls.normalize(device_str)
            # Fail fast on a CUDA device that doesn't exist, rather than starting a worker pinned to
            # it that only errors cryptically at the first tensor allocation. ("auto" only generates
            # valid indices, so this just validates explicitly-configured devices.)
            if device.type == "cuda":
                if not torch.cuda.is_available():
                    raise ValueError(f"generation_devices requested '{device_str}', but no CUDA device is available.")
                if device.index is not None and device.index >= torch.cuda.device_count():
                    raise ValueError(
                        f"generation_devices requested '{device_str}', but only {torch.cuda.device_count()} "
                        f"CUDA device(s) are available (valid indices 0-{torch.cuda.device_count() - 1})."
                    )
            elif device.type == "xpu":
                if not _xpu_is_available():
                    raise ValueError(f"generation_devices requested '{device_str}', but no XPU device is available.")
                if device.index is not None and device.index >= torch.xpu.device_count():
                    raise ValueError(
                        f"generation_devices requested '{device_str}', but only {torch.xpu.device_count()} "
                        f"XPU device(s) are available (valid indices 0-{torch.xpu.device_count() - 1})."
                    )
            elif device.type == "mps" and not torch.backends.mps.is_available():
                raise ValueError(f"generation_devices requested '{device_str}', but MPS is not available.")
            if str(device) not in seen:
                seen.add(str(device))
                devices.append(device)
        return devices

    @classmethod
    def normalize(cls, device: Union[str, torch.device]) -> torch.device:
        """Add the device index to CUDA and XPU devices."""
        device = torch.device(device)
        if device.index is None and device.type == "cuda" and torch.cuda.is_available():
            device = torch.device(device.type, torch.cuda.current_device())

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Switch generation_devices to 'auto', 'cpu', or 'cuda' as appropriate for the host
  2. Install XPU-capable torch/IPEX and Intel GPU drivers if XPU is intended
  3. Verify with torch.xpu.is_available() (or the codebase's _xpu_is_available) before pinning xpu

Example fix

// before
generation_devices: ["xpu:0"]  # host without Intel GPU
// after
generation_devices: ["auto"]
Defensive patterns

Strategy: validation

Validate before calling

import torch
def xpu_available() -> bool:
    try:
        return bool(torch.xpu.device_count())
    except Exception:
        return False
if any(str(d).startswith("xpu") for d in generation_devices) and not xpu_available():
    generation_devices = ["auto"]

Type guard

def is_xpu_config_valid(devices: list[str]) -> bool:
    try:
        has_xpu = bool(torch.xpu.device_count())
    except Exception:
        has_xpu = False
    return all(not d.startswith("xpu") for d in devices) or has_xpu

Try / catch

try:
    devices = DeviceService.get_generation_devices(cfg.generation_devices)
except ValueError as e:
    if "no XPU device is available" in str(e):
        log.warning("XPU unavailable; falling back to auto")
        devices = DeviceService.get_generation_devices(["auto"])
    else:
        raise

Prevention

When it happens

Trigger: Configuring generation_devices 'xpu:*' on hosts without Intel GPU support: no Intel GPU/driver, torch build without XPU support, or IPEX not installed/initialized.

Common situations: Reusing a config from an Intel-GPU machine on an NVIDIA or CPU host; missing intel drivers; XPU-enabled torch wheel not installed.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/73a7e9dbab6e3263. Report an issue: GitHub.