opendatalab/MinerU · error · ValueError

Unsupported lmdeploy device type: {device_type}

Error message

Unsupported lmdeploy device type: {device_type}

What it means

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.

Source

Thrown at mineru/backend/vlm/utils.py:79

    if device_type.lower() in ["ascend", "maca", "camb"]:
        lmdeploy_backend = "pytorch"
    elif device_type.lower() in ["cuda"]:
        import torch
        if not torch.cuda.is_available():
            raise ValueError("CUDA is not available.")
        if is_windows_environment():
            lmdeploy_backend = "turbomind"
        elif is_linux_environment():
            major, minor = torch.cuda.get_device_capability()
            compute_capability = f"{major}.{minor}"
            if version.parse(compute_capability) >= version.parse("8.0"):
                lmdeploy_backend = "pytorch"
            else:
                lmdeploy_backend = "turbomind"
        else:
            raise ValueError("Unsupported operating system.")
    else:
        raise ValueError(f"Unsupported lmdeploy device type: {device_type}")
    return lmdeploy_backend


def set_default_gpu_memory_utilization() -> float:
    from vllm import __version__ as vllm_version
    device = get_device()
    gpu_memory = get_vram(device)
    default_gpu_memory_utilization = 0.5
    if version.parse(vllm_version) >= version.parse("0.11.0") and gpu_memory <= 8:
        default_gpu_memory_utilization = 0.7

    logger.debug(f"vllm_version: {vllm_version}, gpu_memory: {gpu_memory} GB, default_gpu_memory_utilization: {default_gpu_memory_utilization}")
    return default_gpu_memory_utilization


def set_default_batch_size() -> int:
    try:
        device = get_device()

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Use one of the supported device names: cuda, ascend, maca, or camb (matching case-insensitively).
  2. Strip/normalize config values before they reach the engine (device.strip().lower()).
  3. For CPU-only machines choose a different backend entirely (transformers/http-client).

Example fix

# before
set_lmdeploy_backend("gpu")     # ValueError
set_lmdeploy_backend("NPU")      # ValueError

# after
set_lmdeploy_backend("cuda")     # ok
set_lmdeploy_backend("ascend")   # ok
Defensive patterns

Strategy: type-guard

Validate before calling

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

def normalize_device(device: str) -> str:
    d = (device or "").strip().lower()
    if d not in LMDEPLOY_DEVICES:
        raise ValueError(f"device must be one of {sorted(LMDEPLOY_DEVICES)}, got {device!r}")
    return d

Type guard

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

def is_lmdeploy_device(value: object) -> bool:
    return isinstance(value, str) and value.strip().lower() in LMDEPLOY_DEVICES

Try / catch

try:
    backend = set_lmdeploy_backend(device_type)
except ValueError as e:
    if "Unsupported lmdeploy device type" in str(e):
        raise ConfigError("fix lmdeploy_device in config") from e
    raise

Prevention

When it happens

Trigger: Passing device_type values like 'cpu', 'gpu', 'npu', 'rocm', or an empty/misspelled string from kwargs['lmdeploy_device'] or MINERU_LMDEPLOY_DEVICE.

Common situations: Config files authored against other frameworks' device names; 'gpu' used instead of 'cuda'; leftover placeholder values; case/whitespace issues not covered by .lower().

Related errors


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