{"record":{"id":"73a7e9dbab6e3263","repo":"invoke-ai/InvokeAI","slug":"generation-devices-requested-device-str-but-n-73a7e9","errorCode":null,"errorMessage":"generation_devices requested '{device_str}', but no XPU device is available.","messagePattern":"generation_devices requested '(.+?)', but no XPU device is available\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/util/devices.py","lineNumber":305,"sourceCode":"\n        devices: list[torch.device] = []\n        seen: set[str] = set()\n        for device_str in device_strs:\n            device = cls.normalize(device_str)\n            # Fail fast on a CUDA device that doesn't exist, rather than starting a worker pinned to\n            # it that only errors cryptically at the first tensor allocation. (\"auto\" only generates\n            # valid indices, so this just validates explicitly-configured devices.)\n            if device.type == \"cuda\":\n                if not torch.cuda.is_available():\n                    raise ValueError(f\"generation_devices requested '{device_str}', but no CUDA device is available.\")\n                if device.index is not None and device.index >= torch.cuda.device_count():\n                    raise ValueError(\n                        f\"generation_devices requested '{device_str}', but only {torch.cuda.device_count()} \"\n                        f\"CUDA device(s) are available (valid indices 0-{torch.cuda.device_count() - 1}).\"\n                    )\n            elif device.type == \"xpu\":\n                if not _xpu_is_available():\n                    raise ValueError(f\"generation_devices requested '{device_str}', but no XPU device is available.\")\n                if device.index is not None and device.index >= torch.xpu.device_count():\n                    raise ValueError(\n                        f\"generation_devices requested '{device_str}', but only {torch.xpu.device_count()} \"\n                        f\"XPU device(s) are available (valid indices 0-{torch.xpu.device_count() - 1}).\"\n                    )\n            elif device.type == \"mps\" and not torch.backends.mps.is_available():\n                raise ValueError(f\"generation_devices requested '{device_str}', but MPS is not available.\")\n            if str(device) not in seen:\n                seen.add(str(device))\n                devices.append(device)\n        return devices\n\n    @classmethod\n    def normalize(cls, device: Union[str, torch.device]) -> torch.device:\n        \"\"\"Add the device index to CUDA and XPU devices.\"\"\"\n        device = torch.device(device)\n        if device.index is None and device.type == \"cuda\" and torch.cuda.is_available():\n            device = torch.device(device.type, torch.cuda.current_device())","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/util/devices.py#L287-L323","documentation":"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).","triggerScenarios":"Configuring generation_devices 'xpu:*' on hosts without Intel GPU support: no Intel GPU/driver, torch build without XPU support, or IPEX not installed/initialized.","commonSituations":"Reusing a config from an Intel-GPU machine on an NVIDIA or CPU host; missing intel drivers; XPU-enabled torch wheel not installed.","solutions":["Switch generation_devices to 'auto', 'cpu', or 'cuda' as appropriate for the host","Install XPU-capable torch/IPEX and Intel GPU drivers if XPU is intended","Verify with torch.xpu.is_available() (or the codebase's _xpu_is_available) before pinning xpu"],"exampleFix":"// before\ngeneration_devices: [\"xpu:0\"]  # host without Intel GPU\n// after\ngeneration_devices: [\"auto\"]","handlingStrategy":"validation","validationCode":"import torch\ndef xpu_available() -> bool:\n    try:\n        return bool(torch.xpu.device_count())\n    except Exception:\n        return False\nif any(str(d).startswith(\"xpu\") for d in generation_devices) and not xpu_available():\n    generation_devices = [\"auto\"]","typeGuard":"def is_xpu_config_valid(devices: list[str]) -> bool:\n    try:\n        has_xpu = bool(torch.xpu.device_count())\n    except Exception:\n        has_xpu = False\n    return all(not d.startswith(\"xpu\") for d in devices) or has_xpu","tryCatchPattern":"try:\n    devices = DeviceService.get_generation_devices(cfg.generation_devices)\nexcept ValueError as e:\n    if \"no XPU device is available\" in str(e):\n        log.warning(\"XPU unavailable; falling back to auto\")\n        devices = DeviceService.get_generation_devices([\"auto\"])\n    else:\n        raise","preventionTips":["Verify Intel GPU drivers and XPU-capable torch/IPEX before configuring xpu devices","Test with torch.xpu.device_count() at startup","Use 'auto' on non-Intel hosts","Keep per-host device configs instead of sharing pinned xpu settings"],"tags":["config","xpu","device","gpu-unavailable"],"backgroundTag":"cuda-not-available","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}