{"record":{"id":"5e8d1b781ae327be","repo":"opendatalab/MinerU","slug":"unsupported-lmdeploy-device-type-device-type-5e8d1b","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/vlm_analyze.py","lineNumber":189,"sourceCode":"                            from mineru_vl_utils import MinerULogitsProcessor\n                            kwargs[\"logits_processors\"] = [MinerULogitsProcessor]\n                        # 使用kwargs为 vllm初始化参数\n                        vllm_async_llm = AsyncLLM.from_engine_args(AsyncEngineArgs(**kwargs))\n                    elif backend == \"lmdeploy-engine\":\n                        try:\n                            from lmdeploy import PytorchEngineConfig, TurbomindEngineConfig\n                            from lmdeploy.serve.vl_async_engine import VLAsyncEngine\n                        except ImportError:\n                            raise ImportError(\"Please install lmdeploy to use the lmdeploy-engine backend.\")\n                        if \"cache_max_entry_count\" not in kwargs:\n                            kwargs[\"cache_max_entry_count\"] = 0.5\n\n                        device_type = os.getenv(\"MINERU_LMDEPLOY_DEVICE\", \"\")\n                        if device_type == \"\":\n                            if \"lmdeploy_device\" in kwargs:\n                                device_type = kwargs.pop(\"lmdeploy_device\")\n                                if device_type not in [\"cuda\", \"ascend\", \"maca\", \"camb\"]:\n                                    raise ValueError(f\"Unsupported lmdeploy device type: {device_type}\")\n                            else:\n                                device_type = \"cuda\"\n                        lm_backend = os.getenv(\"MINERU_LMDEPLOY_BACKEND\", \"\")\n                        if lm_backend == \"\":\n                            if \"lmdeploy_backend\" in kwargs:\n                                lm_backend = kwargs.pop(\"lmdeploy_backend\")\n                                if lm_backend not in [\"pytorch\", \"turbomind\"]:\n                                    raise ValueError(f\"Unsupported lmdeploy backend: {lm_backend}\")\n                            else:\n                                lm_backend = set_lmdeploy_backend(device_type)\n                        logger.info(f\"lmdeploy device is: {device_type}, lmdeploy backend is: {lm_backend}\")\n\n                        if lm_backend == \"pytorch\":\n                            kwargs[\"device_type\"] = device_type\n                            backend_config = PytorchEngineConfig(**kwargs)\n                        elif lm_backend == \"turbomind\":\n                            backend_config = TurbomindEngineConfig(**kwargs)\n                        else:","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/backend/vlm/vlm_analyze.py#L171-L207","documentation":"Raised while building the lmdeploy-engine VLM backend when the explicitly supplied lmdeploy device type is not one of the supported accelerators. The device is resolved from the MINERU_LMDEPLOY_DEVICE env var first; if unset, the `lmdeploy_device` kwark is checked against the hardcoded whitelist ['cuda','ascend','maca','camb'] before it can influence engine construction.","triggerScenarios":"Calling the VLM analyzer with backend 'vlm-engine' while MINERU_LMDEPLOY_DEVICE is unset and passing kwargs like lmdeploy_device='cpu', lmdeploy_device='npu', or any string outside cuda/ascend/maca/camb (e.g. trailing whitespace or wrong casing such as 'CUDA').","commonSituations":"Users on CPU-only machines trying to force lmdeploy onto CPU; Huawei Ascend users typing 'npu' instead of 'ascend'; typos or uppercase variants; copying configs from other frameworks that use 'gpu'.","solutions":["Set the device to a supported value: cuda, ascend, maca, or camb (exact lowercase)","If you have no supported accelerator, switch to a different backend (e.g. pipeline) or use vlm-http-client against a remote GPU server","Prefer the env var: export MINERU_LMDEPLOY_DEVICE=cuda instead of the kwarg to keep config out of code","Strip/normalize the string before passing: lmdeploy_device=value.strip().lower()"],"exampleFix":"# before\nanalyzer = MineVlmAnalyzer(backend='vlm-engine', lmdeploy_device='NPU')\n\n# after\nanalyzer = MineVlmAnalyzer(backend='vlm-engine', lmdeploy_device='ascend')","handlingStrategy":"validation","validationCode":"SUPPORTED_LMDEPLOY_DEVICES = {\"cuda\", \"ascend\", \"maca\", \"camb\"}\n\ndef resolve_device(explicit: str | None) -> str:\n    device = os.getenv(\"MINERU_LMDEPLOY_DEVICE\", \"\") or explicit or \"cuda\"\n    device = device.strip().lower()\n    if device not in SUPPORTED_LMDEPLOY_DEVICES:\n        raise SystemExit(f\"device must be one of {sorted(SUPPORTED_LMDEPLOY_DEVICES)}, got {device!r}\")\n    return device","typeGuard":null,"tryCatchPattern":"try:\n    analyzer = MineVlmAnalyzer(backend=\"vlm-engine\", lmdeploy_device=device)\nexcept ValueError as e:\n    if \"Unsupported lmdeploy device\" in str(e):\n        device = \"cuda\"  # or surface a config error to the user\n    else:\n        raise","preventionTips":["Export MINERU_LMDEPLOY_DEVICE in your environment/CI template rather than passing kwargs","Normalize device strings with .strip().lower() before passing","Fail fast at config-load time with a whitelist check"],"tags":["lmdeploy","vlm","device","hardware","configuration"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}