MinerU provides extensive support for a wide variety of hardware accelerators, ranging from standard NVIDIA GPUs and Apple Silicon to a broad ecosystem of domestic Chinese AI chips. This hardware abstraction is primarily managed through centralized device detection in config_reader.py and specialized inference engine configurations in the VLM and Pipeline backends.
The system identifies the available hardware at runtime to determine which execution provider to use for models (PyTorch, ONNX Runtime, vLLM, etc.).
The get_device() function in mineru/utils/config_reader.py resolves the execution device using the following priority:
MINERU_DEVICE_MODE mineru/utils/config_reader.py106-108torch.cuda.is_available() mineru/utils/config_reader.py110-111torch.backends.mps.is_available() mineru/utils/config_reader.py112-113The following diagram illustrates how natural language hardware categories map to specific code entities and detection logic within the MinerU codebase.
Title: Hardware Detection and Entity Mapping
Sources: mineru/utils/config_reader.py105-138
The VLM backend contains specialized logic for domestic accelerators, particularly for vllm and lmdeploy engines.
Engine parameters are often adjusted based on the MINERU_VLLM_DEVICE or MINERU_LMDEPLOY_DEVICE environment variables.
MINERU_VLLM_DEVICE=kxpu docs/zh/usage/acceleration_cards/Kunlunxin.md42For lmdeploy, the backend is determined by environment variables:
pytorch backend by setting MINERU_LMDEPLOY_DEVICE to ascend docs/zh/usage/acceleration_cards/Ascend.md77 maca docs/zh/usage/acceleration_cards/METAX.md57 or camb docs/zh/usage/acceleration_cards/Cambricon.md45Sources: mineru/utils/config_reader.py105-138 docs/zh/usage/acceleration_cards/MooreThreads.md44-47 docs/zh/usage/acceleration_cards/Cambricon.md68-71
vllm and lmdeploy. MINERU_LMDEPLOY_DEVICE should be set to ascend docs/zh/usage/acceleration_cards/Ascend.md14-77--enforce-eager --dtype float16 parameters are required for vLLM commands docs/zh/usage/acceleration_cards/Ascend.md89-93ASCEND_RT_VISIBLE_DEVICES for isolation docs/zh/usage/acceleration_cards/Ascend.md174maca.Dockerfile. It supports both vllm and lmdeploy backends docs/zh/usage/acceleration_cards/METAX.md24-36MINERU_LMDEPLOY_DEVICE=maca docs/zh/usage/acceleration_cards/METAX.md57mx-smi docs/zh/usage/acceleration_cards/METAX.md147vllm and lmdeploy via ppu.Dockerfile docs/zh/usage/acceleration_cards/THead.md19-30--device=/dev/alixpu and --device=/dev/alixpu_ctl when running containers docs/zh/usage/acceleration_cards/THead.md38-39ppu-smi docs/zh/usage/acceleration_cards/THead.md138MINERU_VLLM_DEVICE=kxpu docs/zh/usage/acceleration_cards/Kunlunxin.md42XPU_VISIBLE_DEVICES for isolation docs/zh/usage/acceleration_cards/Kunlunxin.md119vlm-engine and vlm-http-client using the vLLM backend docs/zh/usage/acceleration_cards/VastAI.md75-215--enforce_eager docs/zh/usage/acceleration_cards/VastAI.md124VACC_VISIBLE_DEVICES docs/zh/usage/acceleration_cards/VastAI.md69MTHREADS_VISIBLE_DEVICES=all and MINERU_VLLM_DEVICE=musa docs/zh/usage/acceleration_cards/MooreThreads.md29-30vllm across all conversion modes via the sdaa-vllm-latest image docs/zh/usage/acceleration_cards/Tecorigin.md30-106SDAA_VISIBLE_DEVICES docs/zh/usage/acceleration_cards/Tecorigin.md115teco-smi -c docs/zh/usage/acceleration_cards/Tecorigin.md116| Accelerator | Symbol | Visibility Env Var | SMI Tool |
|---|---|---|---|
| Huawei Ascend | npu | ASCEND_RT_VISIBLE_DEVICES | npu-smi |
| Cambricon | mlu | MLU_VISIBLE_DEVICES | cnmon |
| METAX | maca | CUDA_VISIBLE_DEVICES | mx-smi |
| Tecorigin | sdaa | SDAA_VISIBLE_DEVICES | teco-smi |
| T-Head | ppu | PPU_VISIBLE_DEVICES | ppu-smi |
| Kunlunxin | kxpu | XPU_VISIBLE_DEVICES | xpu-smi |
| Hygon DCU | dcu | HIP_VISIBLE_DEVICES | hy-smi |
| Biren | supa | SUPA_VISIBLE_DEVICES | brsmi |
| VastAI | vacc | VACC_VISIBLE_DEVICES | N/A |
| Enflame | gcu | TOPS_VISIBLE_DEVICES | efsmi |
| MooreThreads | musa | MTHREADS_VISIBLE_DEVICES | mthreads-gmi |
Sources: docs/zh/usage/acceleration_cards/Ascend.md docs/zh/usage/acceleration_cards/METAX.md docs/zh/usage/acceleration_cards/THead.md docs/zh/usage/acceleration_cards/Kunlunxin.md docs/zh/usage/acceleration_cards/VastAI.md docs/zh/usage/acceleration_cards/Tecorigin.md docs/zh/usage/acceleration_cards/MooreThreads.md docs/zh/usage/acceleration_cards/Enflame.md104-106 docs/zh/usage/acceleration_cards/Cambricon.md153-155
The system provides utilities to monitor and clean hardware memory to prevent Out-Of-Memory (OOM) errors during long-running batch tasks.
Title: Hardware Memory Lifecycle
Sources: mineru/utils/model_utils.py183-205 mineru/utils/model_utils.py208-212
Many domestic cards (like Ascend 310P and VastAI) require eager mode execution to avoid graph compilation issues or precision mismatches. This is handled by adding --enforce-eager (or --enforce_eager) and specifying --dtype float16 in the engine arguments docs/zh/usage/acceleration_cards/Ascend.md89-93 docs/zh/usage/acceleration_cards/VastAI.md124
The clean_memory() function in mineru/utils/model_utils.py provides device-specific cache clearing for CUDA, NPU, MPS, GCU, MUSA, MLU, and SDAA using their respective empty_cache() implementations mineru/utils/model_utils.py183-205
Sources: docs/zh/usage/acceleration_cards/Ascend.md88-93 docs/zh/usage/acceleration_cards/VastAI.md123-125 mineru/utils/model_utils.py183-205
Refresh this wiki