opendatalab/MinerU · error · ValueError

Unsupported lmdeploy backend: {lm_backend}

Error message

Unsupported lmdeploy backend: {lm_backend}

What it means

Raised when starting the lmdeploy VLM server if the resolved backend is not 'pytorch' or 'turbomind'. The value comes from the function argument overridden by the MINERU_LMDEPLOY_BACKEND env var; an empty value falls back to set_lmdeploy_backend(device_type), which picks a default per device.

Source

Thrown at mineru/model/vlm/lmdeploy_server.py:66

    # 添加默认参数
    if not has_port_arg:
        args.extend(["--server-port", "30000"])
    if not has_gpu_memory_utilization_arg:
        args.extend(["--cache-max-entry-count", "0.5"])
    if not has_log_level_arg:
        args.extend(["--log-level", "ERROR"])

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

    if lm_backend == "pytorch":
        os.environ["TOKENIZERS_PARALLELISM"] = "false"


    args.extend(["--device", device_type])
    args.extend(["--backend", lm_backend])

    model_path = auto_download_and_get_model_root_path("/", "vlm")

    # logger.debug(args)

    # 重构参数,将模型路径作为位置参数
    sys.argv = [sys.argv[0]] + ["serve", "api_server", model_path] + args

    if os.getenv('OMP_NUM_THREADS') is None:
        os.environ["OMP_NUM_THREADS"] = "1"

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Set MINERU_LMDEPLOY_BACKEND to pytorch or turbomind, or unset it to let the device default apply.
  2. On non-CUDA devices the pytorch backend is usually the valid choice.
  3. Remove stale backend env vars from deployment manifests.

Example fix

# before
export MINERU_LMDEPLOY_BACKEND=vlm

# after
export MINERU_LMDEPLOY_BACKEND=pytorch
# or leave unset to auto-select per device
Defensive patterns

Strategy: validation

Validate before calling

import os
VALID_BACKENDS = {"pytorch", "turbomind"}
backend = os.getenv("MINERU_LMDEPLOY_BACKEND", "")
if backend:
    assert backend in VALID_BACKENDS, f"MINERU_LMDEPLOY_BACKEND must be one of {VALID_BACKENDS}, got {backend!r}"

Type guard

def is_supported_lmdeploy_backend(b: str) -> bool:
    return b in {"pytorch", "turbomind"}

Prevention

When it happens

Trigger: Setting MINERU_LMDEPLOY_BACKEND to values like 'vlm', 'transformers', 'trt', or passing lm_backend with such a string when calling the lmdeploy server builder.

Common situations: Confusing lmdeploy backend names with other inference engines; carrying over env vars from other serving stacks; trying to force a backend unsupported for the chosen device.

Related errors


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