opendatalab/MinerU · error · ValueError

Unsupported lmdeploy device type: {device_type}

Error message

Unsupported lmdeploy device type: {device_type}

What it means

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.

Source

Thrown at mineru/backend/vlm/vlm_analyze.py:189

                            from mineru_vl_utils import MinerULogitsProcessor
                            kwargs["logits_processors"] = [MinerULogitsProcessor]
                        # 使用kwargs为 vllm初始化参数
                        vllm_async_llm = AsyncLLM.from_engine_args(AsyncEngineArgs(**kwargs))
                    elif backend == "lmdeploy-engine":
                        try:
                            from lmdeploy import PytorchEngineConfig, TurbomindEngineConfig
                            from lmdeploy.serve.vl_async_engine import VLAsyncEngine
                        except ImportError:
                            raise ImportError("Please install lmdeploy to use the lmdeploy-engine backend.")
                        if "cache_max_entry_count" not in kwargs:
                            kwargs["cache_max_entry_count"] = 0.5

                        device_type = os.getenv("MINERU_LMDEPLOY_DEVICE", "")
                        if device_type == "":
                            if "lmdeploy_device" in kwargs:
                                device_type = kwargs.pop("lmdeploy_device")
                                if device_type not in ["cuda", "ascend", "maca", "camb"]:
                                    raise ValueError(f"Unsupported lmdeploy device type: {device_type}")
                            else:
                                device_type = "cuda"
                        lm_backend = os.getenv("MINERU_LMDEPLOY_BACKEND", "")
                        if lm_backend == "":
                            if "lmdeploy_backend" in kwargs:
                                lm_backend = kwargs.pop("lmdeploy_backend")
                                if lm_backend not in ["pytorch", "turbomind"]:
                                    raise ValueError(f"Unsupported lmdeploy backend: {lm_backend}")
                            else:
                                lm_backend = set_lmdeploy_backend(device_type)
                        logger.info(f"lmdeploy device is: {device_type}, lmdeploy backend is: {lm_backend}")

                        if lm_backend == "pytorch":
                            kwargs["device_type"] = device_type
                            backend_config = PytorchEngineConfig(**kwargs)
                        elif lm_backend == "turbomind":
                            backend_config = TurbomindEngineConfig(**kwargs)
                        else:

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Set the device to a supported value: cuda, ascend, maca, or camb (exact lowercase)
  2. If you have no supported accelerator, switch to a different backend (e.g. pipeline) or use vlm-http-client against a remote GPU server
  3. Prefer the env var: export MINERU_LMDEPLOY_DEVICE=cuda instead of the kwarg to keep config out of code
  4. Strip/normalize the string before passing: lmdeploy_device=value.strip().lower()

Example fix

# before
analyzer = MineVlmAnalyzer(backend='vlm-engine', lmdeploy_device='NPU')

# after
analyzer = MineVlmAnalyzer(backend='vlm-engine', lmdeploy_device='ascend')
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_LMDEPLOY_DEVICES = {"cuda", "ascend", "maca", "camb"}

def resolve_device(explicit: str | None) -> str:
    device = os.getenv("MINERU_LMDEPLOY_DEVICE", "") or explicit or "cuda"
    device = device.strip().lower()
    if device not in SUPPORTED_LMDEPLOY_DEVICES:
        raise SystemExit(f"device must be one of {sorted(SUPPORTED_LMDEPLOY_DEVICES)}, got {device!r}")
    return device

Try / catch

try:
    analyzer = MineVlmAnalyzer(backend="vlm-engine", lmdeploy_device=device)
except ValueError as e:
    if "Unsupported lmdeploy device" in str(e):
        device = "cuda"  # or surface a config error to the user
    else:
        raise

Prevention

When it happens

Trigger: 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').

Common situations: 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'.

Related errors


AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14). Data as JSON: /api/errors/5e8d1b781ae327be. Report an issue: GitHub.