{"record":{"id":"d5c814b4cc01cfd1","repo":"docling-project/docling","slug":"cuda-is-not-supported-by-this-model-supported-dev","errorCode":null,"errorMessage":"CUDA is not supported by this model. Supported devices: {[d.value for d in supported_devices]}","messagePattern":"CUDA is not supported by this model\\. Supported devices: (.+?)","errorType":"exception","errorClass":"AcceleratorDeviceNotAvailableError","httpStatus":null,"severity":"error","filePath":"docling/utils/accelerator_utils.py","lineNumber":60,"sourceCode":"            _log.info(\n                f\"Removing XPU from available devices because it is not in {supported_devices=}\"\n            )\n            has_xpu = False\n\n    if accelerator_device == AcceleratorDevice.AUTO.value:  # Handle 'auto'\n        if has_cuda:\n            device = \"cuda:0\"\n        elif has_mps:\n            device = \"mps\"\n        elif has_xpu:\n            device = \"xpu\"\n\n    elif accelerator_device.startswith(\"cuda\"):\n        if (\n            supported_devices is not None\n            and AcceleratorDevice.CUDA not in supported_devices\n        ):\n            raise AcceleratorDeviceNotAvailableError(\n                f\"CUDA is not supported by this model. Supported devices: {[d.value for d in supported_devices]}\"\n            )\n\n        if has_cuda:\n            # if cuda device index specified extract device id\n            parts = accelerator_device.split(\":\")\n            if len(parts) == 2 and parts[1].isdigit():\n                # select cuda device's id\n                cuda_index = int(parts[1])\n                if cuda_index < torch.cuda.device_count():\n                    device = f\"cuda:{cuda_index}\"\n                else:\n                    raise AcceleratorDeviceNotAvailableError(\n                        f\"CUDA device 'cuda:{cuda_index}' is not available. \"\n                        f\"Available CUDA devices: 0-{torch.cuda.device_count() - 1}\"\n                    )\n            elif len(parts) == 1:  # just \"cuda\"\n                device = \"cuda:0\"","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/utils/accelerator_utils.py#L42-L78","documentation":"AcceleratorDeviceNotAvailableError raised by decide_device() when the user explicitly requests a CUDA device (accelerator_device startswith 'cuda') but the model/pipeline declares supported_devices that excludes AcceleratorDevice.CUDA. It is a hard configuration error: the chosen model cannot run on CUDA regardless of hardware availability.","triggerScenarios":"Setting accelerator_options.accelerator_device='cuda' (or 'cuda:N') in PdfPipelineOptions (or --device cuda in the CLI) while the model being initialized passes supported_devices without CUDA — e.g. a CPU-only or MPS-only model spec in its constructor call to decide_device.","commonSituations":"Mixing third-party/custom model stages into a pipeline and assuming every model supports CUDA; newer model variants restricted to specific backends; passing a device globally via CLI while a specific stage does not support it.","solutions":["Switch the pipeline/stage to a supported device: use accelerator_device='auto' or 'cpu' (auto silently demotes unsupported devices per model)","Check the model's documented supported devices and align accelerator_device accordingly","Configure accelerator device per-model/stage rather than globally if only one stage rejects CUDA","Upgrade docling — supported device sets occasionally widen in newer releases"],"exampleFix":"# before\naccelerator_options.accelerator_device = \"cuda\"\n\n# after\naccelerator_options.accelerator_device = \"auto\"  # falls back per-model supported devices","handlingStrategy":"validation","validationCode":"from docling.datamodel.accelerator_options import AcceleratorDevice\n\nSUPPORTED = {d.value for d in model_supported_devices}  # from the model spec\nif accelerator_options.accelerator_device.startswith(\"cuda\") and \"cuda\" not in SUPPORTED:\n    accelerator_options.accelerator_device = \"auto\"","typeGuard":"def device_supported(requested: str, supported: set[str]) -> bool:\n    base = requested.split(\":\")[0]\n    return requested in supported or base in supported","tryCatchPattern":"from docling.exceptions import AcceleratorDeviceNotAvailableError\n\ntry:\n    device = decide_device(requested, supported_devices)\nexcept AcceleratorDeviceNotAvailableError:\n    device = decide_device(\"auto\", supported_devices)  # per-model demotion","preventionTips":["Default to 'auto' — it demotes unsupported devices per model instead of raising","Consult each model stage's supported_devices before pinning a global device","Set devices per-stage when mixing CUDA and CPU-only models","Re-check supported devices after docling upgrades"],"tags":["cuda","accelerator","configuration","hardware"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}