{"record":{"id":"f9f4d1455f2c97ba","repo":"opendatalab/MinerU","slug":"unsupported-lmdeploy-device-type-device-type","errorCode":null,"errorMessage":"Unsupported lmdeploy device type: {device_type}","messagePattern":"Unsupported lmdeploy device type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/backend/vlm/utils.py","lineNumber":79,"sourceCode":"    if device_type.lower() in [\"ascend\", \"maca\", \"camb\"]:\n        lmdeploy_backend = \"pytorch\"\n    elif device_type.lower() in [\"cuda\"]:\n        import torch\n        if not torch.cuda.is_available():\n            raise ValueError(\"CUDA is not available.\")\n        if is_windows_environment():\n            lmdeploy_backend = \"turbomind\"\n        elif is_linux_environment():\n            major, minor = torch.cuda.get_device_capability()\n            compute_capability = f\"{major}.{minor}\"\n            if version.parse(compute_capability) >= version.parse(\"8.0\"):\n                lmdeploy_backend = \"pytorch\"\n            else:\n                lmdeploy_backend = \"turbomind\"\n        else:\n            raise ValueError(\"Unsupported operating system.\")\n    else:\n        raise ValueError(f\"Unsupported lmdeploy device type: {device_type}\")\n    return lmdeploy_backend\n\n\ndef set_default_gpu_memory_utilization() -> float:\n    from vllm import __version__ as vllm_version\n    device = get_device()\n    gpu_memory = get_vram(device)\n    default_gpu_memory_utilization = 0.5\n    if version.parse(vllm_version) >= version.parse(\"0.11.0\") and gpu_memory <= 8:\n        default_gpu_memory_utilization = 0.7\n\n    logger.debug(f\"vllm_version: {vllm_version}, gpu_memory: {gpu_memory} GB, default_gpu_memory_utilization: {default_gpu_memory_utilization}\")\n    return default_gpu_memory_utilization\n\n\ndef set_default_batch_size() -> int:\n    try:\n        device = get_device()","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/backend/vlm/utils.py#L61-L97","documentation":"Final else of set_lmdeploy_backend(): device_type is not one of ascend/maca/camb (pytorch backend) or cuda. The accepted device vocabulary is fixed, so any other string — including typos and case variants like 'CUDA' handled only via .lower() on the known names — is rejected.","triggerScenarios":"Passing device_type values like 'cpu', 'gpu', 'npu', 'rocm', or an empty/misspelled string from kwargs['lmdeploy_device'] or MINERU_LMDEPLOY_DEVICE.","commonSituations":"Config files authored against other frameworks' device names; 'gpu' used instead of 'cuda'; leftover placeholder values; case/whitespace issues not covered by .lower().","solutions":["Use one of the supported device names: cuda, ascend, maca, or camb (matching case-insensitively).","Strip/normalize config values before they reach the engine (device.strip().lower()).","For CPU-only machines choose a different backend entirely (transformers/http-client)."],"exampleFix":"# before\nset_lmdeploy_backend(\"gpu\")     # ValueError\nset_lmdeploy_backend(\"NPU\")      # ValueError\n\n# after\nset_lmdeploy_backend(\"cuda\")     # ok\nset_lmdeploy_backend(\"ascend\")   # ok","handlingStrategy":"type-guard","validationCode":"LMDEPLOY_DEVICES = {\"ascend\", \"maca\", \"camb\", \"cuda\"}\n\ndef normalize_device(device: str) -> str:\n    d = (device or \"\").strip().lower()\n    if d not in LMDEPLOY_DEVICES:\n        raise ValueError(f\"device must be one of {sorted(LMDEPLOY_DEVICES)}, got {device!r}\")\n    return d","typeGuard":"LMDEPLOY_DEVICES = {\"ascend\", \"maca\", \"camb\", \"cuda\"}\n\ndef is_lmdeploy_device(value: object) -> bool:\n    return isinstance(value, str) and value.strip().lower() in LMDEPLOY_DEVICES","tryCatchPattern":"try:\n    backend = set_lmdeploy_backend(device_type)\nexcept ValueError as e:\n    if \"Unsupported lmdeploy device type\" in str(e):\n        raise ConfigError(\"fix lmdeploy_device in config\") from e\n    raise","preventionTips":["Centralize device strings as constants; forbid free-text device config.","Strip and lower() user input before it reaches the engine.","Reject 'gpu'/'npu' early with a mapping hint ('gpu' -> 'cuda')."],"tags":["lmdeploy","device","validation","configuration"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}