From 056f8af0ae18637e2b2c466033b15f2d17a6f2a5 Mon Sep 17 00:00:00 2001 From: myhloli Date: Fri, 14 Nov 2025 01:33:06 +0800 Subject: [PATCH 01/66] fix: add libglib2.0-0 dependency in npu.Dockerfile for improved package support --- docker/china/npu.Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/china/npu.Dockerfile b/docker/china/npu.Dockerfile index 212b9a8d..3fc47da0 100644 --- a/docker/china/npu.Dockerfile +++ b/docker/china/npu.Dockerfile @@ -8,6 +8,7 @@ RUN apt-get update && \ fonts-noto-cjk \ fontconfig \ libgl1 && \ + libglib2.0-0 && \ fc-cache -fv && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* From d67be0c7de8fd717f648ff5aa2b1c169002c1697 Mon Sep 17 00:00:00 2001 From: myhloli Date: Fri, 14 Nov 2025 10:34:29 +0800 Subject: [PATCH 02/66] fix: add lmdeploy-engine parameters to compose.yaml for improved multi-GPU support --- docker/compose.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docker/compose.yaml b/docker/compose.yaml index 8d37db59..b574a115 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -73,6 +73,9 @@ services: # parameters for vllm-engine # --data-parallel-size 2 # If using multiple GPUs, increase throughput using vllm's multi-GPU parallel mode # --gpu-memory-utilization 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. + # parameters for lmdeploy-engine + # --dp 2 # If using multiple GPUs, increase throughput using lmdeploy's multi-GPU parallel mode + # --cache-max-entry-count 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. ulimits: memlock: -1 stack: 67108864 @@ -98,12 +101,17 @@ services: command: --server-name 0.0.0.0 --server-port 7860 - --enable-vllm-engine true # Enable the vllm engine for Gradio # --enable-api false # If you want to disable the API, set this to false # --max-convert-pages 20 # If you want to limit the number of pages for conversion, set this to a specific number # parameters for vllm-engine + --enable-vllm-engine true # Enable the vllm engine for Gradio # --data-parallel-size 2 # If using multiple GPUs, increase throughput using vllm's multi-GPU parallel mode # --gpu-memory-utilization 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. + # parameters for lmdeploy-engine + # !!!The lmdeploy and vLLM engines cannot be enabled simultaneously. Please ensure that at most only one engine is active at any given time.!!! + # --enable-lmdeploy-engine true # Enable the lmdeploy engine for Gradio + # --dp 2 # If using multiple GPUs, increase throughput using lmdeploy's multi-GPU parallel mode + # --cache-max-entry-count 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. ulimits: memlock: -1 stack: 67108864 From ad9521528e7e37c9029b52090bf2003f884b9c3d Mon Sep 17 00:00:00 2001 From: myhloli Date: Fri, 14 Nov 2025 10:47:16 +0800 Subject: [PATCH 03/66] fix: update base image descriptions in Dockerfiles for clarity on CPU architecture --- docker/china/camb.Dockerfile | 2 +- docker/china/maca.Dockerfile | 2 +- docker/china/npu.Dockerfile | 2 +- docker/china/ppu.Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/china/camb.Dockerfile b/docker/china/camb.Dockerfile index 37ffbe31..52239cc6 100644 --- a/docker/china/camb.Dockerfile +++ b/docker/china/camb.Dockerfile @@ -1,4 +1,4 @@ -# Base image containing the LMDeploy inference environment, requiring amd64 CPU + cambricon MLU. +# Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + cambricon MLU. FROM # Install libgl for opencv support & Noto fonts for Chinese characters diff --git a/docker/china/maca.Dockerfile b/docker/china/maca.Dockerfile index ba40c4ef..de3c6f2c 100644 --- a/docker/china/maca.Dockerfile +++ b/docker/china/maca.Dockerfile @@ -1,4 +1,4 @@ -# Base image containing the LMDeploy inference environment, requiring amd64 CPU + metax GPU. +# Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + metax GPU. FROM # Install libgl for opencv support & Noto fonts for Chinese characters diff --git a/docker/china/npu.Dockerfile b/docker/china/npu.Dockerfile index 3fc47da0..a4d0ffc9 100644 --- a/docker/china/npu.Dockerfile +++ b/docker/china/npu.Dockerfile @@ -1,4 +1,4 @@ -# Base image containing the LMDeploy inference environment, requiring ARM CPU + Ascend NPU. +# Base image containing the LMDeploy inference environment, requiring ARM(AArch64) CPU + Ascend NPU. FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ascend:mineru-a2 # Install libgl for opencv support & Noto fonts for Chinese characters diff --git a/docker/china/ppu.Dockerfile b/docker/china/ppu.Dockerfile index 53a76a10..a54d6584 100644 --- a/docker/china/ppu.Dockerfile +++ b/docker/china/ppu.Dockerfile @@ -1,4 +1,4 @@ -# Base image containing the LMDeploy inference environment, requiring amd64 CPU + t-head PPU. +# Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + t-head PPU. FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ppu:mineru-ppu # Install libgl for opencv support & Noto fonts for Chinese characters From 43881d5f66f1ecf1afeca56c6ddbc2560b86f490 Mon Sep 17 00:00:00 2001 From: myhloli Date: Mon, 17 Nov 2025 11:24:03 +0800 Subject: [PATCH 04/66] fix: update index.md and README files for improved clarity on lmdeploy-engine support --- README.md | 4 ++-- README_zh-CN.md | 4 ++-- docs/en/quick_start/index.md | 24 ++++++++++++++---------- docs/zh/quick_start/index.md | 24 ++++++++++++++---------- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 63a08e2c..87625912 100644 --- a/README.md +++ b/README.md @@ -714,8 +714,8 @@ uv pip install -e .[core] ``` > [!TIP] -> `mineru[core]` includes all core features except `vLLM` acceleration, compatible with Windows / Linux / macOS systems, suitable for most users. -> If you need to use `vLLM` acceleration for VLM model inference or install a lightweight client on edge devices, please refer to the documentation [Extension Modules Installation Guide](https://opendatalab.github.io/MinerU/quick_start/extension_modules/). +> `mineru[core]` includes all core features except `vLLM`/`LMDeploy` acceleration, compatible with Windows / Linux / macOS systems, suitable for most users. +> If you need to use `vLLM`/`LMDeploy` acceleration for VLM model inference or install a lightweight client on edge devices, please refer to the documentation [Extension Modules Installation Guide](https://opendatalab.github.io/MinerU/quick_start/extension_modules/). --- diff --git a/README_zh-CN.md b/README_zh-CN.md index 64e2a2ff..cecc891c 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -704,8 +704,8 @@ uv pip install -e .[core] -i https://mirrors.aliyun.com/pypi/simple ``` > [!TIP] -> `mineru[core]`包含除`vLLM`加速外的所有核心功能,兼容Windows / Linux / macOS系统,适合绝大多数用户。 -> 如果您有使用`vLLM`加速VLM模型推理,或是在边缘设备安装轻量版client端等需求,可以参考文档[扩展模块安装指南](https://opendatalab.github.io/MinerU/zh/quick_start/extension_modules/)。 +> `mineru[core]`包含除`vLLM`/`LMDeploy`加速外的所有核心功能,兼容Windows / Linux / macOS系统,适合绝大多数用户。 +> 如果您需要使用`vLLM`/`LMDeploy`加速VLM模型推理,或是有在边缘设备安装轻量版client端等需求,可以参考文档[扩展模块安装指南](https://opendatalab.github.io/MinerU/zh/quick_start/extension_modules/)。 --- diff --git a/docs/en/quick_start/index.md b/docs/en/quick_start/index.md index cc349ba7..0be3b2ae 100644 --- a/docs/en/quick_start/index.md +++ b/docs/en/quick_start/index.md @@ -31,12 +31,13 @@ A WebUI developed based on Gradio, with a simple interface and only core parsing Parsing Backend pipeline
(Accuracy1 82+) - vlm (Accuracy1 90+) + vlm (Accuracy1 90+) transformers mlx-engine vllm-engine /
vllm-async-engine + lmdeploy-engine http-client @@ -47,40 +48,42 @@ A WebUI developed based on Gradio, with a simple interface and only core parsing Good compatibility,
but slower Faster than transformers Fast, compatible with the vLLM ecosystem - Suitable for OpenAI-compatible servers5 + Fast, compatible with the LMDeploy ecosystem + Suitable for OpenAI-compatible servers6 Operating System Linux2 / Windows / macOS macOS3 Linux2 / Windows4 + Linux2 / Windows5 Any CPU inference support ✅ - ❌ + ❌ Not required GPU RequirementsVolta or later architectures, 6 GB VRAM or more, or Apple Silicon Apple Silicon - Volta or later architectures, 8 GB VRAM or more + Volta or later architectures, 8 GB VRAM or more Not required Memory Requirements - Minimum 16 GB, 32 GB recommended + Minimum 16 GB, 32 GB recommended 8 GB Disk Space Requirements - 20 GB or more, SSD recommended + 20 GB or more, SSD recommended 2 GB Python Version - 3.10-3.13 + 3.10-3.13 @@ -89,7 +92,8 @@ A WebUI developed based on Gradio, with a simple interface and only core parsing 2 Linux supports only distributions released in 2019 or later. 3 MLX requires macOS 13.5 or later, recommended for use with version 14.0 or higher. 4 Windows vLLM support via WSL2(Windows Subsystem for Linux). -5 Servers compatible with the OpenAI API, such as local or remote model services deployed via inference frameworks like `vLLM`, `SGLang`, or `LMDeploy`. +5 Windows LMDeploy can only use the `turbomind` backend, which is slightly slower than the `pytorch` backend. If performance is critical, it is recommended to run it via WSL2. +6 Servers compatible with the OpenAI API, such as local or remote model services deployed via inference frameworks like `vLLM`, `SGLang`, or `LMDeploy`. ### Install MinerU @@ -108,8 +112,8 @@ uv pip install -e .[core] ``` > [!TIP] -> `mineru[core]` includes all core features except `vllm` acceleration, compatible with Windows / Linux / macOS systems, suitable for most users. -> If you need to use `vllm` acceleration for VLM model inference or install a lightweight client on edge devices, please refer to the documentation [Extension Modules Installation Guide](./extension_modules.md). +> `mineru[core]` includes all core features except `vLLM`/`LMDeploy` acceleration, compatible with Windows / Linux / macOS systems, suitable for most users. +> If you need to use `vLLM`/`LMDeploy` acceleration for VLM model inference or install a lightweight client on edge devices, please refer to the documentation [Extension Modules Installation Guide](./extension_modules.md). --- diff --git a/docs/zh/quick_start/index.md b/docs/zh/quick_start/index.md index d00258b3..657184a1 100644 --- a/docs/zh/quick_start/index.md +++ b/docs/zh/quick_start/index.md @@ -31,12 +31,13 @@ 解析后端 pipeline
(精度1 82+) - vlm (精度1 90+) + vlm (精度1 90+) transformers mlx-engine vllm-engine /
vllm-async-engine + lmdeploy-engine http-client @@ -47,40 +48,42 @@ 兼容性好, 速度较慢 比transformers快 速度快, 兼容vllm生态 - 适用于OpenAI兼容服务器5 + 速度快, 兼容lmdeploy生态 + 适用于OpenAI兼容服务器6 操作系统 Linux2 / Windows / macOS macOS3 Linux2 / Windows4 + Linux2 / Windows5 不限 CPU推理支持 ✅ - ❌ + ❌ 不需要 GPU要求Volta及以后架构, 6G显存以上或Apple Silicon Apple Silicon - Volta及以后架构, 8G显存以上 + Volta及以后架构, 8G显存以上 不需要 内存要求 - 最低16GB以上, 推荐32GB以上 + 最低16GB以上, 推荐32GB以上 8GB 磁盘空间要求 - 20GB以上, 推荐使用SSD + 20GB以上, 推荐使用SSD 2GB python版本 - 3.10-3.13 + 3.10-3.13 @@ -89,7 +92,8 @@ 2 Linux仅支持2019年及以后发行版 3 MLX需macOS 13.5及以上版本支持,推荐14.0以上版本使用 4 Windows vLLM通过WSL2(适用于 Linux 的 Windows 子系统)实现支持 -5 兼容OpenAI API的服务器,如通过`vLLM`/`SGLang`/`LMDeploy`等推理框架部署的本地模型服务器或远程模型服务 +5 Windows LMDeploy只能使用`turbomind`后端,速度比`pytorch`后端稍慢,如对速度有要求建议通过WSL2运行 +6 兼容OpenAI API的服务器,如通过`vLLM`/`SGLang`/`LMDeploy`等推理框架部署的本地模型服务器或远程模型服务 > [!TIP] > 除以上主流环境与平台外,我们也收录了一些社区用户反馈的其他平台支持情况,详情请参考[其他加速卡适配](https://opendatalab.github.io/MinerU/zh/usage/)。 @@ -113,8 +117,8 @@ uv pip install -e .[core] -i https://mirrors.aliyun.com/pypi/simple ``` > [!TIP] -> `mineru[core]`包含除`vllm`加速外的所有核心功能,兼容Windows / Linux / macOS系统,适合绝大多数用户。 -> 如果您有使用`vllm`加速VLM模型推理,或是在边缘设备安装轻量版client端等需求,可以参考文档[扩展模块安装指南](./extension_modules.md)。 +> `mineru[core]`包含除`vLLM`/`LMDeploy`加速外的所有核心功能,兼容Windows / Linux / macOS系统,适合绝大多数用户。 +> 如果您需要使用`vLLM`/`LMDeploy`加速VLM模型推理,或是有在边缘设备安装轻量版client端等需求,可以参考文档[扩展模块安装指南](./extension_modules.md)。 --- From 506179f0c82aaf3905afe4e5c8c2d0d7826a1db0 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 15:28:19 +0800 Subject: [PATCH 05/66] feat: add openai-server command for flexible inference engine selection in vlm_server --- mineru/cli/vlm_server.py | 33 +++++++++++++++++++++++++++++++++ pyproject.toml | 1 + 2 files changed, 34 insertions(+) diff --git a/mineru/cli/vlm_server.py b/mineru/cli/vlm_server.py index ebf51c99..c26121ac 100644 --- a/mineru/cli/vlm_server.py +++ b/mineru/cli/vlm_server.py @@ -1,3 +1,7 @@ +import click +import sys + +from loguru import logger def vllm_server(): @@ -8,3 +12,32 @@ def vllm_server(): def lmdeploy_server(): from mineru.model.vlm.lmdeploy_server import main main() + + +@click.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True)) +@click.option( + '-e', + '--engine', + 'inference_engine', + type=click.Choice(['auto', 'vllm', 'lmdeploy']), + default='auto', + help='Select the inference engine used to accelerate VLM inference, default is "auto".', +) +@click.pass_context +def openai_server(ctx, inference_engine): + sys.argv = [sys.argv[0]] + ctx.args + if inference_engine == 'auto': + try: + import vllm + inference_engine = 'vllm' + logger.info("Using vLLM as the inference engine for VLM server.") + except ImportError: + inference_engine = 'lmdeploy' + logger.info("vLLM not found, falling back to LMDeploy as the inference engine for VLM server.") + if inference_engine == 'vllm': + vllm_server() + elif inference_engine == 'lmdeploy': + lmdeploy_server() + +if __name__ == "__main__": + openai_server() \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f0262842..4c39554f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,6 +111,7 @@ issues = "https://github.com/opendatalab/MinerU/issues" mineru = "mineru.cli:client.main" mineru-vllm-server = "mineru.cli.vlm_server:vllm_server" mineru-lmdeploy-server = "mineru.cli.vlm_server:lmdeploy_server" +mineru-openai-server = "mineru.cli.vlm_server:openai_server" mineru-models-download = "mineru.cli.models_download:download_models" mineru-api = "mineru.cli.fast_api:main" mineru-gradio = "mineru.cli.gradio_app:main" From 843ab52da01e6bf0ec086bd330f9f4f45708d8ea Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 15:51:14 +0800 Subject: [PATCH 06/66] fix: rename vllm-server to openai-server in compose.yaml for clarity and update command parameters --- docker/compose.yaml | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/docker/compose.yaml b/docker/compose.yaml index b574a115..00e5a4f6 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -1,19 +1,27 @@ services: - mineru-vllm-server: + mineru-openai-server: image: mineru:latest - container_name: mineru-vllm-server + container_name: mineru-openai-server restart: always - profiles: ["vllm-server"] + profiles: ["openai-server"] ports: - 30000:30000 environment: MINERU_MODEL_SOURCE: local - entrypoint: mineru-vllm-server + entrypoint: mineru-openai-server command: + # !!!The lmdeploy and vLLM engines cannot be enabled simultaneously.!!! + --engine vllm # Choose between 'vllm' or 'lmdeploy' engine + # parameters for vllm-engine --host 0.0.0.0 --port 30000 # --data-parallel-size 2 # If using multiple GPUs, increase throughput using vllm's multi-GPU parallel mode # --gpu-memory-utilization 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. + # parameters for lmdeploy-engine + # --server-name 0.0.0.0 + # --server-port 30000 + # --dp 2 # If using multiple GPUs, increase throughput using lmdeploy's multi-GPU parallel mode + # --cache-max-entry-count 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. ulimits: memlock: -1 stack: 67108864 @@ -28,35 +36,6 @@ services: device_ids: ["0"] capabilities: [gpu] - mineru-lmdeploy-server: - image: mineru:latest - container_name: mineru-lmdeploy-server - restart: always - profiles: [ "lmdeploy-server" ] - ports: - - 30000:30000 - environment: - MINERU_MODEL_SOURCE: local - entrypoint: mineru-lmdeploy-server - command: - --host 0.0.0.0 - --port 30000 - # --dp 2 # If using multiple GPUs, increase throughput using lmdeploy's multi-GPU parallel mode - # --cache-max-entry-count 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. - ulimits: - memlock: -1 - stack: 67108864 - ipc: host - healthcheck: - test: [ "CMD-SHELL", "curl -f http://localhost:30000/health || exit 1" ] - deploy: - resources: - reservations: - devices: - - driver: nvidia - device_ids: [ "0" ] - capabilities: [ gpu ] - mineru-api: image: mineru:latest container_name: mineru-api From a149a8da500b14471fbfe31e679f846774bda750 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 15:58:25 +0800 Subject: [PATCH 07/66] fix: enhance comments in compose.yaml for clearer engine selection and GPU configuration guidance --- docker/compose.yaml | 91 ++++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 31 deletions(-) diff --git a/docker/compose.yaml b/docker/compose.yaml index 00e5a4f6..ccaa3a1f 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -10,18 +10,29 @@ services: MINERU_MODEL_SOURCE: local entrypoint: mineru-openai-server command: - # !!!The lmdeploy and vLLM engines cannot be enabled simultaneously.!!! - --engine vllm # Choose between 'vllm' or 'lmdeploy' engine - # parameters for vllm-engine + # ==================== Engine Selection ==================== + # WARNING: Only ONE engine can be enabled at a time! + # Choose 'vllm' OR 'lmdeploy' (uncomment one line below) + --engine vllm + # --engine lmdeploy + + # ==================== vLLM Engine Parameters ==================== + # Uncomment if using --engine vllm --host 0.0.0.0 --port 30000 - # --data-parallel-size 2 # If using multiple GPUs, increase throughput using vllm's multi-GPU parallel mode - # --gpu-memory-utilization 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. - # parameters for lmdeploy-engine + # Multi-GPU configuration (increase throughput) + # --data-parallel-size 2 + # Single GPU memory optimization (reduce if VRAM insufficient) + # --gpu-memory-utilization 0.5 # Try 0.4 or lower if issues persist + + # ==================== LMDeploy Engine Parameters ==================== + # Uncomment if using --engine lmdeploy # --server-name 0.0.0.0 - # --server-port 30000 - # --dp 2 # If using multiple GPUs, increase throughput using lmdeploy's multi-GPU parallel mode - # --cache-max-entry-count 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. + # --server-port 30000 + # Multi-GPU configuration (increase throughput) + # --dp 2 + # Single GPU memory optimization (reduce if VRAM insufficient) + # --cache-max-entry-count 0.5 # Try 0.4 or lower if issues persist ulimits: memlock: -1 stack: 67108864 @@ -33,7 +44,7 @@ services: reservations: devices: - driver: nvidia - device_ids: ["0"] + device_ids: ["0"] # Modify for multiple GPUs: ["0", "1"] capabilities: [gpu] mineru-api: @@ -47,14 +58,21 @@ services: MINERU_MODEL_SOURCE: local entrypoint: mineru-api command: + # ==================== Server Configuration ==================== --host 0.0.0.0 --port 8000 - # parameters for vllm-engine - # --data-parallel-size 2 # If using multiple GPUs, increase throughput using vllm's multi-GPU parallel mode - # --gpu-memory-utilization 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. - # parameters for lmdeploy-engine - # --dp 2 # If using multiple GPUs, increase throughput using lmdeploy's multi-GPU parallel mode - # --cache-max-entry-count 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. + + # ==================== vLLM Engine Parameters ==================== + # Multi-GPU configuration + # --data-parallel-size 2 + # Single GPU memory optimization + # --gpu-memory-utilization 0.5 # Try 0.4 or lower if VRAM insufficient + + # ==================== LMDeploy Engine Parameters ==================== + # Multi-GPU configuration + # --dp 2 + # Single GPU memory optimization + # --cache-max-entry-count 0.5 # Try 0.4 or lower if VRAM insufficient ulimits: memlock: -1 stack: 67108864 @@ -64,8 +82,8 @@ services: reservations: devices: - driver: nvidia - device_ids: [ "0" ] - capabilities: [ gpu ] + device_ids: ["0"] # Modify for multiple GPUs: ["0", "1"] + capabilities: [gpu] mineru-gradio: image: mineru:latest @@ -78,19 +96,30 @@ services: MINERU_MODEL_SOURCE: local entrypoint: mineru-gradio command: + # ==================== Gradio Server Configuration ==================== --server-name 0.0.0.0 --server-port 7860 - # --enable-api false # If you want to disable the API, set this to false - # --max-convert-pages 20 # If you want to limit the number of pages for conversion, set this to a specific number - # parameters for vllm-engine - --enable-vllm-engine true # Enable the vllm engine for Gradio - # --data-parallel-size 2 # If using multiple GPUs, increase throughput using vllm's multi-GPU parallel mode - # --gpu-memory-utilization 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. - # parameters for lmdeploy-engine - # !!!The lmdeploy and vLLM engines cannot be enabled simultaneously. Please ensure that at most only one engine is active at any given time.!!! - # --enable-lmdeploy-engine true # Enable the lmdeploy engine for Gradio - # --dp 2 # If using multiple GPUs, increase throughput using lmdeploy's multi-GPU parallel mode - # --cache-max-entry-count 0.5 # If running on a single GPU and encountering VRAM shortage, reduce the KV cache size by this parameter, if VRAM issues persist, try lowering it further to `0.4` or below. + + # ==================== Gradio Feature Settings ==================== + # --enable-api false # Disable API endpoint + # --max-convert-pages 20 # Limit conversion page count + + # ==================== Engine Selection ==================== + # WARNING: Only ONE engine can be enabled at a time! + + # Option 1: vLLM Engine (recommended for most users) + --enable-vllm-engine true + # Multi-GPU configuration + # --data-parallel-size 2 + # Single GPU memory optimization + # --gpu-memory-utilization 0.5 # Try 0.4 or lower if VRAM insufficient + + # Option 2: LMDeploy Engine + # --enable-lmdeploy-engine true + # Multi-GPU configuration + # --dp 2 + # Single GPU memory optimization + # --cache-max-entry-count 0.5 # Try 0.4 or lower if VRAM insufficient ulimits: memlock: -1 stack: 67108864 @@ -100,5 +129,5 @@ services: reservations: devices: - driver: nvidia - device_ids: [ "0" ] - capabilities: [ gpu ] + device_ids: ["0"] # Modify for multiple GPUs: ["0", "1"] + capabilities: [gpu] From 10af19f419ac0c8f55afdc9f0850fb4b7ed600a4 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 16:36:59 +0800 Subject: [PATCH 08/66] fix: update docker_deployment.md and extension_modules.md for clarity on GPU architecture requirements and service naming --- docs/en/quick_start/docker_deployment.md | 13 +++++------ docs/en/quick_start/extension_modules.md | 29 +++++++++++++++++++----- docs/zh/quick_start/docker_deployment.md | 15 ++++++------ docs/zh/quick_start/extension_modules.md | 29 ++++++++++++++++++------ 4 files changed, 58 insertions(+), 28 deletions(-) diff --git a/docs/en/quick_start/docker_deployment.md b/docs/en/quick_start/docker_deployment.md index eb4406a9..533e12a2 100644 --- a/docs/en/quick_start/docker_deployment.md +++ b/docs/en/quick_start/docker_deployment.md @@ -20,7 +20,7 @@ MinerU's Docker uses `vllm/vllm-openai` as the base image, so it includes the `v > [!NOTE] > Requirements for using `vllm` to accelerate VLM model inference: > -> - Device must have Turing architecture or later graphics cards with 8GB+ available VRAM. +> - Device must have Volta architecture or later graphics cards with 8GB+ available VRAM. > - The host machine's graphics driver should support CUDA 12.8 or higher; You can check the driver version using the `nvidia-smi` command. > - Docker container must have access to the host machine's graphics devices. @@ -51,17 +51,17 @@ wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/compose.yaml > >- The `compose.yaml` file contains configurations for multiple services of MinerU, you can choose to start specific services as needed. >- Different services might have additional parameter configurations, which you can view and edit in the `compose.yaml` file. ->- Due to the pre-allocation of GPU memory by the `vllm` inference acceleration framework, you may not be able to run multiple `vllm` services simultaneously on the same machine. Therefore, ensure that other services that might use GPU memory have been stopped before starting the `vlm-vllm-server` service or using the `vlm-vllm-engine` backend. +>- Due to the pre-allocation of GPU memory by the `vllm` inference acceleration framework, you may not be able to run multiple `vllm` services simultaneously on the same machine. Therefore, ensure that other services that might use GPU memory have been stopped before starting the `vlm-openai-server` service or using the `vlm-vllm-engine` backend. --- -### Start vllm-server service -connect to `vllm-server` via `vlm-http-client` backend +### Start OpenAI-compatible server service +connect to `openai-server` via `vlm-http-client` backend ```bash - docker compose -f compose.yaml --profile vllm-server up -d + docker compose -f compose.yaml --profile openai-server up -d ``` >[!TIP] - >In another terminal, connect to vllm server via http client (only requires CPU and network, no vllm environment needed) + >In another terminal, connect to openai server via http client (only requires CPU and network, no vllm environment needed) > ```bash > mineru -p -o -b vlm-http-client -u http://:30000 > ``` @@ -84,4 +84,3 @@ connect to `vllm-server` via `vlm-http-client` backend >[!TIP] > >- Access `http://:7860` in your browser to use the Gradio WebUI. - >- Access `http://:7860/?view=api` to use the Gradio API. diff --git a/docs/en/quick_start/extension_modules.md b/docs/en/quick_start/extension_modules.md index ea772fa8..492dbdf0 100644 --- a/docs/en/quick_start/extension_modules.md +++ b/docs/en/quick_start/extension_modules.md @@ -4,7 +4,7 @@ MinerU supports installing extension modules on demand based on different needs ## Common Scenarios ### Core Functionality Installation -The `core` module is the core dependency of MinerU, containing all functional modules except `vllm`. Installing this module ensures the basic functionality of MinerU works properly. +The `core` module is the core dependency of MinerU, containing all functional modules except `vllm`/`lmdeploy`. Installing this module ensures the basic functionality of MinerU works properly. ```bash uv pip install "mineru[core]" ``` @@ -12,18 +12,35 @@ uv pip install "mineru[core]" --- ### Using `vllm` to Accelerate VLM Model Inference -The `vllm` module provides acceleration support for VLM model inference, suitable for graphics cards with Turing architecture and later (8GB+ VRAM). Installing this module can significantly improve model inference speed. -In the configuration, `all` includes both `core` and `vllm` modules, so `mineru[all]` and `mineru[core,vllm]` are equivalent. +> [!NOTE] +> `vllm` and `lmdeploy` have nearly identical VLM inference acceleration effects and usage methods. You can choose one of them to install and use based on your actual needs, but it is not recommended to install both modules simultaneously to avoid potential dependency conflicts. + +The `vllm` module provides acceleration support for VLM model inference, suitable for graphics cards with Volta architecture and later (8GB+ VRAM). Installing this module can significantly improve model inference speed. + ```bash -uv pip install "mineru[all]" +uv pip install "mineru[core,vllm]" ``` > [!TIP] > If exceptions occur during installation of the complete package including vllm, please refer to the [vllm official documentation](https://docs.vllm.ai/en/latest/getting_started/installation/index.html) to try to resolve the issue, or directly use the [Docker](./docker_deployment.md) deployment method. --- -### Installing Lightweight Client to Connect to vllm-server -If you need to install a lightweight client on edge devices to connect to `vllm-server`, you can install the basic mineru package, which is very lightweight and suitable for devices with only CPU and network connectivity. +### Using `lmdeploy` to Accelerate VLM Model Inference +> [!NOTE] +> `vllm` and `lmdeploy` have nearly identical VLM inference acceleration effects and usage methods. You can choose one of them to install and use based on your actual needs, but it is not recommended to install both modules simultaneously to avoid potential dependency conflicts. + +The `lmdeploy` module provides acceleration support for VLM model inference, suitable for graphics cards with Volta architecture and later (8GB+ VRAM). Installing this module can significantly improve model inference speed. + +```bash +uv pip install "mineru[core,lmdeploy]" +``` +> [!TIP] +> If exceptions occur during installation of the complete package including lmdeploy, please refer to the [lmdeploy official documentation](https://lmdeploy.readthedocs.io/en/latest/get_started/installation.html) to try to resolve the issue. + +--- + +### Installing Lightweight Client to Connect to OpenAI-compatible servers +If you need to install a lightweight client on edge devices to connect to an OpenAI-compatible server for using VLM mode, you can install the basic mineru package, which is very lightweight and suitable for devices with only CPU and network connectivity. ```bash uv pip install mineru ``` diff --git a/docs/zh/quick_start/docker_deployment.md b/docs/zh/quick_start/docker_deployment.md index e8ee07a4..4a97590b 100644 --- a/docs/zh/quick_start/docker_deployment.md +++ b/docs/zh/quick_start/docker_deployment.md @@ -19,7 +19,7 @@ Mineru的docker使用了`vllm/vllm-openai`作为基础镜像,因此在docker > [!NOTE] > 使用`vllm`加速VLM模型推理需要满足的条件是: > -> - 设备包含Turing及以后架构的显卡,且可用显存大于等于8G。 +> - 设备包含Volta及以后架构的显卡,且可用显存大于等于8G。 > - 物理机的显卡驱动应支持CUDA 12.8或更高版本,可通过`nvidia-smi`命令检查驱动版本。 > - docker中能够访问物理机的显卡设备。 @@ -50,17 +50,17 @@ wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/compose.yaml > >- `compose.yaml`文件中包含了MinerU的多个服务配置,您可以根据需要选择启动特定的服务。 >- 不同的服务可能会有额外的参数配置,您可以在`compose.yaml`文件中查看并编辑。 ->- 由于`vllm`推理加速框架预分配显存的特性,您可能无法在同一台机器上同时运行多个`vllm`服务,因此请确保在启动`vlm-vllm-server`服务或使用`vlm-vllm-engine`后端时,其他可能使用显存的服务已停止。 +>- 由于`vllm`推理加速框架预分配显存的特性,您可能无法在同一台机器上同时运行多个`vllm`服务,因此请确保在启动`vlm-openai-server`服务或使用`vlm-vllm-engine`后端时,其他可能使用显存的服务已停止。 --- -### 启动 vllm-server 服务 -并通过`vlm-http-client`后端连接`vllm-server` +### 启动 openai兼容接口 服务 +并通过`vlm-http-client`后端连接`openai-server` ```bash - docker compose -f compose.yaml --profile vllm-server up -d + docker compose -f compose.yaml --profile openai-server up -d ``` >[!TIP] - >在另一个终端中通过http client连接vllm server(只需cpu与网络,不需要vllm环境) + >在另一个终端中通过http client连接openai server(只需cpu与网络,不需要vllm环境) > ```bash > mineru -p -o -b vlm-http-client -u http://:30000 > ``` @@ -82,5 +82,4 @@ wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/compose.yaml ``` >[!TIP] > - >- 在浏览器中访问 `http://:7860` 使用 Gradio WebUI。 - >- 访问 `http://:7860/?view=api` 使用 Gradio API。 \ No newline at end of file + >- 在浏览器中访问 `http://:7860` 使用 Gradio WebUI。 \ No newline at end of file diff --git a/docs/zh/quick_start/extension_modules.md b/docs/zh/quick_start/extension_modules.md index 97534bff..b45f724a 100644 --- a/docs/zh/quick_start/extension_modules.md +++ b/docs/zh/quick_start/extension_modules.md @@ -4,7 +4,7 @@ MinerU 支持根据不同需求,按需安装扩展模块,以增强功能或 ## 常见场景 ### 核心功能安装 -`core` 模块是 MinerU 的核心依赖,包含了除`vllm`外的所有功能模块。安装此模块可以确保 MinerU 的基本功能正常运行。 +`core` 模块是 MinerU 的核心依赖,包含了除`vllm`/`lmdeploy`外的所有功能模块。安装此模块可以确保 MinerU 的基本功能正常运行。 ```bash uv pip install "mineru[core]" ``` @@ -12,18 +12,33 @@ uv pip install "mineru[core]" --- ### 使用`vllm`加速 VLM 模型推理 -`vllm` 模块提供了对 VLM 模型推理的加速支持,适用于具有 Turing 及以后架构的显卡(8G 显存及以上)。安装此模块可以显著提升模型推理速度。 -在配置中,`all`包含了`core`和`vllm`模块,因此`mineru[all]`和`mineru[core,vllm]`是等价的。 +> [!NOTE] +> `vllm`和`lmdeploy`对vlm的推理加速效果和使用方式几乎相同,您可以根据实际情况选择其中之一进行安装和使用,但不建议同时安装这两个模块,以避免潜在的依赖冲突。 + +`vllm` 模块提供了对 VLM 模型推理的加速支持,适用于具有 Volta 及以后架构的显卡(8G 显存及以上)。安装此模块可以显著提升模型推理速度。 ```bash -uv pip install "mineru[all]" +uv pip install "mineru[core,vllm]" ``` > [!TIP] -> 如在安装包含vllm的完整包过程中发生异常,请参考 [vllm 官方文档](https://docs.vllm.ai/en/latest/getting_started/installation/index.html) 尝试解决,或直接使用 [Docker](./docker_deployment.md) 方式部署镜像。 +> 如在安装包含`vllm`的完整包过程中发生异常,请参考 [vllm 官方文档](https://docs.vllm.ai/en/latest/getting_started/installation/index.html) 尝试解决,或直接使用 [Docker](./docker_deployment.md) 方式部署镜像。 --- -### 安装轻量版client连接vllm-server使用 -如果您需要在边缘设备上安装轻量版的 client 端以连接 `vllm-server`,可以安装mineru的基础包,非常轻量,适合在只有cpu和网络连接的设备上使用。 +### 使用`lmdeploy`加速 VLM 模型推理 +> [!NOTE] +> `vllm`和`lmdeploy`对vlm的推理加速效果和使用方式几乎相同,您可以根据实际情况选择其中之一进行安装和使用,但不建议同时安装这两个模块,以避免潜在的依赖冲突。 + +`lmdeploy` 模块提供了对 VLM 模型推理的加速支持,适用于具有 Volta 及以后架构的显卡(8G 显存及以上)。安装此模块可以显著提升模型推理速度。 +```bash +uv pip install "mineru[core,lmdeploy]" +``` +> [!TIP] +> 如在安装包含`lmdeploy`的完整包过程中发生异常,请参考 [lmdeploy 官方文档](https://lmdeploy.readthedocs.io/en/latest/get_started/installation.html) 尝试解决。 + +--- + +### 安装轻量版client连接兼容openai服务器使用 +如果您需要在边缘设备上安装轻量版的 client 端以连接兼容 openai 接口的服务端来使用vlm模式,可以安装mineru的基础包,非常轻量,适合在只有cpu和网络连接的设备上使用。 ```bash uv pip install mineru ``` From 80445f24bf061fd62d0121ce09cd769ef3d9f04a Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 19:05:58 +0800 Subject: [PATCH 09/66] fix: remove commented-out official vllm image lines in Dockerfile for cleaner configuration --- docker/china/Dockerfile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docker/china/Dockerfile b/docker/china/Dockerfile index c1a9d51a..a31d1e13 100644 --- a/docker/china/Dockerfile +++ b/docker/china/Dockerfile @@ -2,15 +2,9 @@ # Compute Capability version query (https://developer.nvidia.com/cuda-gpus) FROM docker.m.daocloud.io/vllm/vllm-openai:v0.10.1.1 -# Use the official vllm image -# FROM vllm/vllm-openai:v0.10.1.1 - # Use DaoCloud mirrored vllm image for China region for gpu with Turing architecture and below (Compute Capability<8.0) # FROM docker.m.daocloud.io/vllm/vllm-openai:v0.10.2 -# Use the official vllm image -# FROM vllm/vllm-openai:v0.10.2 - # Install libgl for opencv support & Noto fonts for Chinese characters RUN apt-get update && \ apt-get install -y \ From 281c965213e7abdcf15c10640680d7ff5b8ff677 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 20:06:58 +0800 Subject: [PATCH 10/66] fix: update Ascend.md and cli_tools.md for improved clarity on environment setup and backend options --- docker/china/npu.Dockerfile | 11 +- docs/en/usage/cli_tools.md | 2 +- docs/zh/usage/acceleration_cards/Ascend.md | 112 ++++++++++----------- docs/zh/usage/cli_tools.md | 2 +- docs/zh/usage/index.md | 2 +- 5 files changed, 66 insertions(+), 63 deletions(-) diff --git a/docker/china/npu.Dockerfile b/docker/china/npu.Dockerfile index a4d0ffc9..65eedae7 100644 --- a/docker/china/npu.Dockerfile +++ b/docker/china/npu.Dockerfile @@ -1,5 +1,12 @@ +# 基础镜像配置 # Base image containing the LMDeploy inference environment, requiring ARM(AArch64) CPU + Ascend NPU. -FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ascend:mineru-a2 +FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ascend:mineru-a2 AS lmdeploy +# Base image containing the vLLM inference environment, requiring ARM(AArch64) CPU + Ascend NPU. +FROM quay.io/ascend/vllm-ascend:v0.11.0rc1 AS vllm + +# 默认使用 lmdeploy +ARG INFERENCE_ENGINE=lmdeploy +FROM ${INFERENCE_ENGINE} AS final # Install libgl for opencv support & Noto fonts for Chinese characters RUN apt-get update && \ @@ -7,7 +14,7 @@ RUN apt-get update && \ fonts-noto-core \ fonts-noto-cjk \ fontconfig \ - libgl1 && \ + libgl1 \ libglib2.0-0 && \ fc-cache -fv && \ apt-get clean && \ diff --git a/docs/en/usage/cli_tools.md b/docs/en/usage/cli_tools.md index ccffbc43..c8432117 100644 --- a/docs/en/usage/cli_tools.md +++ b/docs/en/usage/cli_tools.md @@ -11,7 +11,7 @@ Options: -p, --path PATH Input file path or directory (required) -o, --output PATH Output directory (required) -m, --method [auto|txt|ocr] Parsing method: auto (default), txt, ocr (pipeline backend only) - -b, --backend [pipeline|vlm-transformers|vlm-vllm-engine|vlm-http-client] + -b, --backend [pipeline|vlm-transformers|vlm-vllm-engine|vlm-lmdeploy-engine|vlm-http-client] Parsing backend (default: pipeline) -l, --lang [ch|ch_server|ch_lite|en|korean|japan|chinese_cht|ta|te|ka|th|el|latin|arabic|east_slavic|cyrillic|devanagari] Specify document language (improves OCR accuracy, pipeline backend only) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 10352efc..48e0622d 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -1,64 +1,60 @@ -#### 1 系统 -NAME="Ubuntu" -VERSION="20.04.6 LTS (Focal Fossa)" -昇腾910B2 -驱动 23.0.6.2 -CANN 7.5.X -Miner U 2.1.9 -#### 2 踩坑记录 -坑1: **图形库相关的问题,总之就是动态库导致TLS的内存分配失败(OpenCV库在ARM64架构上的兼容性问题)** -⭐这个错误 ImportError: /lib/aarch64-linux-gnu/libGLdispatch.so.0: cannot allocate memory in static TLS block 是由于OpenCV库在ARM64架构上的兼容性问题导致的。从错误堆栈可以看到,问题出现在导入cv2模块时,这发生在MinerU的VLM后端初始化过程中。 -解决方法: -1 安装减少内存问题的opencv版本 +## 1. 测试平台 +``` +os: CTyunOS 22.06 +cpu: Kunpeng-920 (aarch64) +npu: Ascend 910B2 +driver: 23.0.3 +docker: 20.10.12 ``` -pip install --upgrade albumentations albucore simsimd# Uninstall current opencv -pip uninstall opencv-python opencv-contrib-python -# Install headless version (no GUI dependencies) -pip install opencv-python-headless +## 2. 环境准备 -python -c "import cv2; print(cv2.__version__)"2 apt-get install一些包 -``` -换成清华源然后重命名为sources.list.tuna,然后挪到根目录下面 -``` -deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse -deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse -deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse -deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiversesudo apt-get update -o Dir::Etc::sourcelist="sources.list.tuna" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -sudo apt-get install libgl1-mesa-glx -o Dir::Etc::sourcelist="sources.list.tuna" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -sudo apt-get install libglib2.0-0 libsm6 libxext6 libxrender-dev libgomp1 -o Dir::Etc::sourcelist="sources.list.tuna" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -sudo apt-get install libgl1-mesa-dev libgles2-mesa-dev -o Dir::Etc::sourcelist="sources.list.tuna" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -sudo apt-get install libgomp1 -o Dir::Etc::sourcelist="sources.list.tuna" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -export OPENCV_IO_ENABLE_OPENEXR=0 export QT_QPA_PLATFORM=offscreen -``` -↑这些不知道哪些好使,或者有没有好使的 +Ascend加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: -3 强制覆盖conda环境自带的动态库(conda的和系统的冲突) -``` -查找:find /usr/lib /lib /root/.local/conda -name "libgomp.so*" 2>/dev/null -export LD_PRELOAD="/usr/lib/aarch64-linux-gnu/libstdc++.so.6:/usr/lib/aarch64-linux-gnu/libgomp.so.1" -export LD_PRELOAD=/lib/aarch64-linux-gnu/libGLdispatch.so.0:$LD_PRELOAD -``` -此外,还可以把conda环境中自带的的强制挪走 -``` -mv $CONDA_PREFIX/lib/libstdc++.so.6 $CONDA_PREFIX/lib/libstdc++.so.6.bak -mv $CONDA_PREFIX/lib/libgomp.so.1 $CONDA_PREFIX/lib/libgomp.so.1.bak -mv $CONDA_PREFIX/lib/libGLdispatch.so.0 $CONDA_PREFIX/lib/libGLdispatch.so.0.bak # 如果有的话 -simsimd包相关: -mv /root/.local/conda/envs/pdfparser/lib/python3.10/site-packages/simsimd./libgomp-947d5fa1.so.1.0.0 /root/.local/conda/envs/pdfparser/lib/python3.10/site-packages/simsimd./libgomp-947d5fa1.so.1.0.0.bak -``` -或者: -降级simsimd 3.7.2 -降级albumentations 1.3.1 -sklean包相关: -``` -# 找到 scikit-learn 内部的 libgomp 路径 -SKLEARN_LIBGOMP="/root/.local/conda/envs/pdfparser/lib/python3.10/site-packages/scikit_learn.libs/libgomp-947d5fa1.so.1.0.0" +### 2.1 使用 lmdeploy -# 预加载这个特定的 libgomp 版本 -export LD_PRELOAD="$SKLEARN_LIBGOMP:$LD_PRELOAD" +#### 使用 Dockerfile 构建镜像 + +```bash +wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile +docker build --build-arg INFERENCE_ENGINE=lmdeploy -t mineru:latest -f npu.Dockerfile . ``` -4 其他 -torch / torch_npu 2.5.1 -pip install "numpy<2.0" 2.0和昇腾不兼容 -export MINERU_MODEL_SOURCE=modelscope + + +### 2.2 使用 vllm + +#### 使用 Dockerfile 构建镜像 + +```bash +wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile +docker build --build-arg INFERENCE_ENGINE=vllm -t mineru:latest -f npu.Dockerfile . +``` + +## 3. 启动 Docker 容器 + +```bash +docker run -u root --name mineru_docker --privileged=true \ + -p 30000:30000 -p 7860:7860 -p 8000:8000 \ + --ipc=host \ + --network=host \ + --device=/dev/davinci0 \ + --device=/dev/davinci1 \ + --device=/dev/davinci2 \ + --device=/dev/davinci3 \ + --device=/dev/davinci4 \ + --device=/dev/davinci5 \ + --device=/dev/davinci6 \ + --device=/dev/davinci7 \ + --device=/dev/davinci_manager \ + --device=/dev/devmm_svm \ + --device=/dev/hisi_hdc \ + -v /var/log/npu/:/usr/slog \ + -v /usr/local/dcmi:/usr/local/dcmi \ + -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ + -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \ + -itd mineru:latest \ + /bin/bash +``` + +执行该命令后,您将进入到Docker容器的交互式终端,并映射了一些端口用于可能会使用的服务,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 +您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 \ No newline at end of file diff --git a/docs/zh/usage/cli_tools.md b/docs/zh/usage/cli_tools.md index 218da1e2..9c3b6aa6 100644 --- a/docs/zh/usage/cli_tools.md +++ b/docs/zh/usage/cli_tools.md @@ -11,7 +11,7 @@ Options: -p, --path PATH 输入文件路径或目录(必填) -o, --output PATH 输出目录(必填) -m, --method [auto|txt|ocr] 解析方法:auto(默认)、txt、ocr(仅用于 pipeline 后端) - -b, --backend [pipeline|vlm-transformers|vlm-vllm-engine|vlm-http-client] + -b, --backend [pipeline|vlm-transformers|vlm-vllm-engine|vlm-lmdeploy-engine|vlm-http-client] 解析后端(默认为 pipeline) -l, --lang [ch|ch_server|ch_lite|en|korean|japan|chinese_cht|ta|te|ka|th|el|latin|arabic|east_slavic|cyrillic|devanagari] 指定文档语言(可提升 OCR 准确率,仅用于 pipeline 后端) diff --git a/docs/zh/usage/index.md b/docs/zh/usage/index.md index 8940bb39..ca44611e 100644 --- a/docs/zh/usage/index.md +++ b/docs/zh/usage/index.md @@ -21,7 +21,7 @@ * [BISHENG](plugin/BISHENG.md) * [RagFlow](plugin/RagFlow.md) - 其他加速卡适配(由社区贡献) - * [昇腾 Ascend](acceleration_cards/Ascend.md) [#3233](https://github.com/opendatalab/MinerU/discussions/3233) + * [昇腾 Ascend](acceleration_cards/Ascend.md) * [沐曦 METAX](acceleration_cards/METAX.md) [#3477](https://github.com/opendatalab/MinerU/pull/3477) * [AMD](acceleration_cards/AMD.md) [#3662](https://github.com/opendatalab/MinerU/discussions/3662) * [太初元碁 Tecorigin](acceleration_cards/Tecorigin.md) [#3767](https://github.com/opendatalab/MinerU/pull/3767) From 669b6cd62944e72f38d7d84288fd6e76a3dfa154 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 20:21:26 +0800 Subject: [PATCH 11/66] fix: update Ascend.md and npu.Dockerfile for improved clarity on Docker image tags and usage instructions --- docker/china/npu.Dockerfile | 7 ++----- docs/zh/usage/acceleration_cards/Ascend.md | 11 +++++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docker/china/npu.Dockerfile b/docker/china/npu.Dockerfile index 65eedae7..9994591c 100644 --- a/docker/china/npu.Dockerfile +++ b/docker/china/npu.Dockerfile @@ -1,12 +1,9 @@ # 基础镜像配置 # Base image containing the LMDeploy inference environment, requiring ARM(AArch64) CPU + Ascend NPU. -FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ascend:mineru-a2 AS lmdeploy +FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ascend:mineru-a2 # Base image containing the vLLM inference environment, requiring ARM(AArch64) CPU + Ascend NPU. -FROM quay.io/ascend/vllm-ascend:v0.11.0rc1 AS vllm +# FROM quay.io/ascend/vllm-ascend:v0.11.0rc1 -# 默认使用 lmdeploy -ARG INFERENCE_ENGINE=lmdeploy -FROM ${INFERENCE_ENGINE} AS final # Install libgl for opencv support & Noto fonts for Chinese characters RUN apt-get update && \ diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 48e0622d..d6674735 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -17,17 +17,17 @@ Ascend加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请 ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile -docker build --build-arg INFERENCE_ENGINE=lmdeploy -t mineru:latest -f npu.Dockerfile . +docker build --build-arg INFERENCE_ENGINE=lmdeploy -t mineru:lmdeploy-latest -f npu.Dockerfile . ``` - ### 2.2 使用 vllm #### 使用 Dockerfile 构建镜像 ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile -docker build --build-arg INFERENCE_ENGINE=vllm -t mineru:latest -f npu.Dockerfile . +# 下载 Dockerfile后,使用编辑器打开并注释掉第3行的基础镜像,打开第5行的基础镜像后再执行后续操作 +docker build --build-arg INFERENCE_ENGINE=vllm -t mineru:vllm-latest -f npu.Dockerfile . ``` ## 3. 启动 Docker 容器 @@ -52,9 +52,12 @@ docker run -u root --name mineru_docker --privileged=true \ -v /usr/local/dcmi:/usr/local/dcmi \ -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \ - -itd mineru:latest \ + -itd mineru:lmdeploy-latest \ /bin/bash ``` +>[!TIP] +> 请根据实际情况选择使用`lmdeploy`或`vllm`版本的镜像,替换上述命令中的`mineru:lmdeploy-latest`为`mineru:vllm-latest`即可。 + 执行该命令后,您将进入到Docker容器的交互式终端,并映射了一些端口用于可能会使用的服务,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 \ No newline at end of file From f8af29e3a15eb2d17aae1c3e9e3dcb3d1a3160b6 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 20:32:50 +0800 Subject: [PATCH 12/66] fix: simplify Docker build commands in Ascend.md for clarity --- docs/zh/usage/acceleration_cards/Ascend.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index d6674735..9ab3312d 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -17,7 +17,7 @@ Ascend加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请 ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile -docker build --build-arg INFERENCE_ENGINE=lmdeploy -t mineru:lmdeploy-latest -f npu.Dockerfile . +docker build -t mineru:lmdeploy-latest -f npu.Dockerfile . ``` ### 2.2 使用 vllm @@ -27,7 +27,7 @@ docker build --build-arg INFERENCE_ENGINE=lmdeploy -t mineru:lmdeploy-latest -f ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile # 下载 Dockerfile后,使用编辑器打开并注释掉第3行的基础镜像,打开第5行的基础镜像后再执行后续操作 -docker build --build-arg INFERENCE_ENGINE=vllm -t mineru:vllm-latest -f npu.Dockerfile . +docker build -t mineru:vllm-latest -f npu.Dockerfile . ``` ## 3. 启动 Docker 容器 From 9ed6636ad26c3e61c1506760ba0336146e1697de Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 20:52:07 +0800 Subject: [PATCH 13/66] fix: update Ascend.md to use --network=host in Docker build commands for improved network configuration --- docs/zh/usage/acceleration_cards/Ascend.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 9ab3312d..aabf1ce1 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -17,7 +17,7 @@ Ascend加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请 ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile -docker build -t mineru:lmdeploy-latest -f npu.Dockerfile . +docker build --network=host -t mineru:lmdeploy-latest -f npu.Dockerfile . ``` ### 2.2 使用 vllm @@ -27,7 +27,7 @@ docker build -t mineru:lmdeploy-latest -f npu.Dockerfile . ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile # 下载 Dockerfile后,使用编辑器打开并注释掉第3行的基础镜像,打开第5行的基础镜像后再执行后续操作 -docker build -t mineru:vllm-latest -f npu.Dockerfile . +docker build --network=host -t mineru:vllm-latest -f npu.Dockerfile . ``` ## 3. 启动 Docker 容器 From 5f9fdd9b626d325f6fed9f73538a11613d93a8e3 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 21:05:41 +0800 Subject: [PATCH 14/66] fix: update npu.Dockerfile to set TORCH_DEVICE_BACKEND_AUTOLOAD=0 for model download --- docker/china/npu.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/china/npu.Dockerfile b/docker/china/npu.Dockerfile index 9994591c..73cf904a 100644 --- a/docker/china/npu.Dockerfile +++ b/docker/china/npu.Dockerfile @@ -22,7 +22,7 @@ RUN python3 -m pip install -U 'mineru[core]' -i https://mirrors.aliyun.com/pypi/ python3 -m pip cache purge # Download models and update the configuration file -RUN /bin/bash -c "mineru-models-download -s modelscope -m all" +RUN TORCH_DEVICE_BACKEND_AUTOLOAD=0 /bin/bash -c "mineru-models-download -s modelscope -m all" # Set the entry point to activate the virtual environment and run the command line tool ENTRYPOINT ["/bin/bash", "-c", "export MINERU_MODEL_SOURCE=local && exec \"$@\"", "--"] \ No newline at end of file From 46f8c6d0821b6c2f1e0386bb732f86c107e47dc5 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 21:10:42 +0800 Subject: [PATCH 15/66] fix: update Ascend.md for clarity in Dockerfile editing instructions --- docs/zh/usage/acceleration_cards/Ascend.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index aabf1ce1..488062f0 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -26,7 +26,7 @@ docker build --network=host -t mineru:lmdeploy-latest -f npu.Dockerfile . ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile -# 下载 Dockerfile后,使用编辑器打开并注释掉第3行的基础镜像,打开第5行的基础镜像后再执行后续操作 +# 下载 Dockerfile后,使用编辑器打开并注释掉第3行的基础镜像,解除注释第5行的基础镜像后再执行后续操作 docker build --network=host -t mineru:vllm-latest -f npu.Dockerfile . ``` From a0f27bd80b64b357d502594ccd541ae9e51ab15e Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 18 Nov 2025 21:20:52 +0800 Subject: [PATCH 16/66] fix: remove unnecessary port mappings in Docker run command for Ascend.md --- docs/zh/usage/acceleration_cards/Ascend.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 488062f0..2c1ad2fb 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -34,7 +34,6 @@ docker build --network=host -t mineru:vllm-latest -f npu.Dockerfile . ```bash docker run -u root --name mineru_docker --privileged=true \ - -p 30000:30000 -p 7860:7860 -p 8000:8000 \ --ipc=host \ --network=host \ --device=/dev/davinci0 \ @@ -52,7 +51,7 @@ docker run -u root --name mineru_docker --privileged=true \ -v /usr/local/dcmi:/usr/local/dcmi \ -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \ - -itd mineru:lmdeploy-latest \ + -it mineru:lmdeploy-latest \ /bin/bash ``` From cf1fbd2923aa17ee333d106a04d222f656111a8d Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 19 Nov 2025 14:41:01 +0800 Subject: [PATCH 17/66] fix: enhance device and backend configuration handling in lmdeploy and vlm modules --- mineru/backend/vlm/vlm_analyze.py | 29 ++++++++++++++++------------- mineru/cli/vlm_server.py | 19 ++++++++++++++++++- mineru/model/vlm/lmdeploy_server.py | 2 ++ 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/mineru/backend/vlm/vlm_analyze.py b/mineru/backend/vlm/vlm_analyze.py index 736a0522..296a9766 100644 --- a/mineru/backend/vlm/vlm_analyze.py +++ b/mineru/backend/vlm/vlm_analyze.py @@ -132,19 +132,22 @@ class ModelSingleton: if "cache_max_entry_count" not in kwargs: kwargs["cache_max_entry_count"] = 0.5 - 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" - - 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) + 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": diff --git a/mineru/cli/vlm_server.py b/mineru/cli/vlm_server.py index c26121ac..a4cf9dca 100644 --- a/mineru/cli/vlm_server.py +++ b/mineru/cli/vlm_server.py @@ -32,11 +32,28 @@ def openai_server(ctx, inference_engine): inference_engine = 'vllm' logger.info("Using vLLM as the inference engine for VLM server.") except ImportError: - inference_engine = 'lmdeploy' logger.info("vLLM not found, falling back to LMDeploy as the inference engine for VLM server.") + try: + import lmdeploy + inference_engine = 'lmdeploy' + logger.info("Using LMDeploy as the inference engine for VLM server.") + except ImportError: + logger.error("Neither vLLM nor LMDeploy is installed. Please install at least one of them.") + sys.exit(1) + if inference_engine == 'vllm': + try: + import vllm + except ImportError: + logger.error("vLLM is not installed. Please install vLLM or choose LMDeploy as the inference engine.") + sys.exit(1) vllm_server() elif inference_engine == 'lmdeploy': + try: + import lmdeploy + except ImportError: + logger.error("LMDeploy is not installed. Please install LMDeploy or choose vLLM as the inference engine.") + sys.exit(1) lmdeploy_server() if __name__ == "__main__": diff --git a/mineru/model/vlm/lmdeploy_server.py b/mineru/model/vlm/lmdeploy_server.py index 248c2d83..655acb98 100644 --- a/mineru/model/vlm/lmdeploy_server.py +++ b/mineru/model/vlm/lmdeploy_server.py @@ -53,10 +53,12 @@ def main(): 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"]: From afc6dcd7b026c4f3a2aa66c31f47e4931e1dbacf Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 19 Nov 2025 14:41:23 +0800 Subject: [PATCH 18/66] fix: update mineru-vl-utils version and add qwen_vl_utils dependency in pyproject.toml --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4c39554f..8330efd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,8 @@ dependencies = [ "openai>=1.70.0,<3", "beautifulsoup4>=4.13.5,<5", "magika>=0.6.2,<1.1.0", - "mineru-vl-utils>=0.1.15,<1", + "mineru-vl-utils>=0.1.16,<1", + "qwen_vl_utils>=0.0.14,<0.1", ] [project.optional-dependencies] @@ -60,7 +61,6 @@ vllm = [ ] lmdeploy = [ "lmdeploy>=0.10.2,<0.11", - "qwen_vl_utils>=0.0.14,<0.1", ] mlx = [ "mlx-vlm>=0.3.3,<0.4", From 76b1a559f88fa602bf5ebc5479a362ab095d4048 Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 19 Nov 2025 19:18:30 +0800 Subject: [PATCH 19/66] fix: add MINERU_LMDEPLOY_DEVICE environment variable and update Ascend.md with usage scenarios --- docs/zh/usage/acceleration_cards/Ascend.md | 96 +++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 2c1ad2fb..56d66296 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -51,6 +51,7 @@ docker run -u root --name mineru_docker --privileged=true \ -v /usr/local/dcmi:/usr/local/dcmi \ -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \ + -e MINERU_LMDEPLOY_DEVICE=ascend \ -it mineru:lmdeploy-latest \ /bin/bash ``` @@ -59,4 +60,97 @@ docker run -u root --name mineru_docker --privileged=true \ > 请根据实际情况选择使用`lmdeploy`或`vllm`版本的镜像,替换上述命令中的`mineru:lmdeploy-latest`为`mineru:vllm-latest`即可。 执行该命令后,您将进入到Docker容器的交互式终端,并映射了一些端口用于可能会使用的服务,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 -您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 \ No newline at end of file +您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 + +## 4. 注意事项 + +不同环境下,MinerU对Ascend加速卡的支持情况如下表所示: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
使用场景环境
vllmlmdeploy
命令行工具(mineru)pipeline✅✅
vllm-transformers✅✅
vllm-vllm-engine❌✅
vllm-http-client✅✅
fastapi服务(mineru-api)pipeline✅✅
vllm-transformers✅✅
vllm-vllm-async-engine✅✅
vllm-http-client✅✅
gradio界面(mineru-gradio)pipeline✅✅
vllm-transformers✅✅
vllm-vllm-async-engine✅✅
vllm-http-client✅✅
openai-server服务(mineru-openai-server)✅✅
数据并行 (--data-parallel-size/--dp)✅❌
+ From 422ee671d828ae191bb701c9185498333af3d77f Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 19 Nov 2025 19:32:08 +0800 Subject: [PATCH 20/66] fix: update installation tips in extension_modules.md to clarify package terminology --- docs/en/quick_start/extension_modules.md | 4 ++-- docs/zh/quick_start/extension_modules.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/en/quick_start/extension_modules.md b/docs/en/quick_start/extension_modules.md index 492dbdf0..c67443d0 100644 --- a/docs/en/quick_start/extension_modules.md +++ b/docs/en/quick_start/extension_modules.md @@ -21,7 +21,7 @@ The `vllm` module provides acceleration support for VLM model inference, suitabl uv pip install "mineru[core,vllm]" ``` > [!TIP] -> If exceptions occur during installation of the complete package including vllm, please refer to the [vllm official documentation](https://docs.vllm.ai/en/latest/getting_started/installation/index.html) to try to resolve the issue, or directly use the [Docker](./docker_deployment.md) deployment method. +> If exceptions occur during installation of the extra package including vllm, please refer to the [vllm official documentation](https://docs.vllm.ai/en/latest/getting_started/installation/index.html) to try to resolve the issue, or directly use the [Docker](./docker_deployment.md) deployment method. --- @@ -35,7 +35,7 @@ The `lmdeploy` module provides acceleration support for VLM model inference, sui uv pip install "mineru[core,lmdeploy]" ``` > [!TIP] -> If exceptions occur during installation of the complete package including lmdeploy, please refer to the [lmdeploy official documentation](https://lmdeploy.readthedocs.io/en/latest/get_started/installation.html) to try to resolve the issue. +> If exceptions occur during installation of the extra package including lmdeploy, please refer to the [lmdeploy official documentation](https://lmdeploy.readthedocs.io/en/latest/get_started/installation.html) to try to resolve the issue. --- diff --git a/docs/zh/quick_start/extension_modules.md b/docs/zh/quick_start/extension_modules.md index b45f724a..6c6c08f6 100644 --- a/docs/zh/quick_start/extension_modules.md +++ b/docs/zh/quick_start/extension_modules.md @@ -20,7 +20,7 @@ uv pip install "mineru[core]" uv pip install "mineru[core,vllm]" ``` > [!TIP] -> 如在安装包含`vllm`的完整包过程中发生异常,请参考 [vllm 官方文档](https://docs.vllm.ai/en/latest/getting_started/installation/index.html) 尝试解决,或直接使用 [Docker](./docker_deployment.md) 方式部署镜像。 +> 如在安装包含`vllm`的扩展包过程中发生异常,请参考 [vllm 官方文档](https://docs.vllm.ai/en/latest/getting_started/installation/index.html) 尝试解决,或直接使用 [Docker](./docker_deployment.md) 方式部署镜像。 --- @@ -33,7 +33,7 @@ uv pip install "mineru[core,vllm]" uv pip install "mineru[core,lmdeploy]" ``` > [!TIP] -> 如在安装包含`lmdeploy`的完整包过程中发生异常,请参考 [lmdeploy 官方文档](https://lmdeploy.readthedocs.io/en/latest/get_started/installation.html) 尝试解决。 +> 如在安装包含`lmdeploy`的扩展包过程中发生异常,请参考 [lmdeploy 官方文档](https://lmdeploy.readthedocs.io/en/latest/get_started/installation.html) 尝试解决。 --- From c5385af754f9307d191ed50bb4c34002cc4bbf9c Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 19 Nov 2025 19:35:54 +0800 Subject: [PATCH 21/66] fix: update advanced_cli_parameters.md to clarify parameter passing for vllm and lmdeploy --- docs/en/usage/advanced_cli_parameters.md | 13 +++++++------ docs/zh/usage/advanced_cli_parameters.md | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/en/usage/advanced_cli_parameters.md b/docs/en/usage/advanced_cli_parameters.md index dd379702..9b571446 100644 --- a/docs/en/usage/advanced_cli_parameters.md +++ b/docs/en/usage/advanced_cli_parameters.md @@ -1,8 +1,8 @@ # Advanced Command Line Parameters -## vllm Acceleration Parameter Optimization +## Pass-through of inference engine parameters -### Performance Optimization Parameters +### vllm Acceleration Parameter Optimization > [!TIP] > If you can already use vllm normally for accelerated VLM model inference but still want to further improve inference speed, you can try the following parameters: > @@ -10,8 +10,9 @@ ### Parameter Passing Instructions > [!TIP] -> - All officially supported vllm parameters can be passed to MinerU through command line arguments, including the following commands: `mineru`, `mineru-vllm-server`, `mineru-gradio`, `mineru-api` +> - All officially supported vllm/lmdeploy parameters can be passed to MinerU through command line arguments, including the following commands: `mineru`, `mineru-openai-server`, `mineru-gradio`, `mineru-api` > - If you want to learn more about `vllm` parameter usage, please refer to the [vllm official documentation](https://docs.vllm.ai/en/latest/cli/serve.html) +> - If you want to learn more about `lmdeploy` parameter usage, please refer to the [lmdeploy official documentation](https://lmdeploy.readthedocs.io/en/latest/llm/api_server.html) ## GPU Device Selection and Configuration @@ -21,7 +22,7 @@ > ```bash > CUDA_VISIBLE_DEVICES=1 mineru -p -o > ``` -> - This specification method is effective for all command line calls, including `mineru`, `mineru-vllm-server`, `mineru-gradio`, and `mineru-api`, and applies to both `pipeline` and `vlm` backends. +> - This specification method is effective for all command line calls, including `mineru`, `mineru-openai-server`, `mineru-gradio`, and `mineru-api`, and applies to both `pipeline` and `vlm` backends. ### Common Device Configuration Examples > [!TIP] @@ -38,9 +39,9 @@ > [!TIP] > Here are some possible usage scenarios: > -> - If you have multiple graphics cards and need to specify cards 0 and 1, using multi-card parallelism to start `vllm-server`, you can use the following command: +> - If you have multiple graphics cards and need to specify cards 0 and 1, using multi-card parallelism to start `openai-server`, you can use the following command: > ```bash -> CUDA_VISIBLE_DEVICES=0,1 mineru-vllm-server --port 30000 --data-parallel-size 2 +> CUDA_VISIBLE_DEVICES=0,1 mineru-openai-server --engine vllm --port 30000 --data-parallel-size 2 > ``` > > - If you have multiple graphics cards and need to start two `fastapi` services on cards 0 and 1, listening on different ports respectively, you can use the following commands: diff --git a/docs/zh/usage/advanced_cli_parameters.md b/docs/zh/usage/advanced_cli_parameters.md index c8f3925b..5c94ee1a 100644 --- a/docs/zh/usage/advanced_cli_parameters.md +++ b/docs/zh/usage/advanced_cli_parameters.md @@ -1,8 +1,8 @@ # 命令行参数进阶 -## vllm 加速参数优化 +## 推理引擎参数透传 -### 性能优化参数 +### vllm 加速参数优化 > [!TIP] > 如果您已经可以正常使用vllm对vlm模型进行加速推理,但仍然希望进一步提升推理速度,可以尝试以下参数: > @@ -10,8 +10,9 @@ ### 参数传递说明 > [!TIP] -> - 所有vllm官方支持的参数都可用通过命令行参数传递给 MinerU,包括以下命令:`mineru`、`mineru-vllm-server`、`mineru-gradio`、`mineru-api` +> - 所有vllm/lmdeploy官方支持的参数都可用通过命令行参数传递给 MinerU,包括以下命令:`mineru`、`mineru-openai-server`、`mineru-gradio`、`mineru-api` > - 如果您想了解更多有关`vllm`的参数使用方法,请参考 [vllm官方文档](https://docs.vllm.ai/en/latest/cli/serve.html) +> - 如果您想了解更多有关`lmdeploy`的参数使用方法,请参考 [lmdeploy官方文档](https://lmdeploy.readthedocs.io/en/latest/llm/api_server.html) ## GPU 设备选择与配置 @@ -21,7 +22,7 @@ > ```bash > CUDA_VISIBLE_DEVICES=1 mineru -p -o > ``` -> - 这种指定方式对所有的命令行调用都有效,包括 `mineru`、`mineru-vllm-server`、`mineru-gradio` 和 `mineru-api`,且对`pipeline`、`vlm`后端均适用。 +> - 这种指定方式对所有的命令行调用都有效,包括 `mineru`、`mineru-openai-server`、`mineru-gradio` 和 `mineru-api`,且对`pipeline`、`vlm`后端均适用。 ### 常见设备配置示例 > [!TIP] @@ -39,9 +40,9 @@ > [!TIP] > 以下是一些可能的使用场景: > -> - 如果您有多张显卡,需要指定卡0和卡1,并使用多卡并行来启动`vllm-server`,可以使用以下命令: +> - 如果您有多张显卡,需要指定卡0和卡1,并使用多卡并行来启动`openai-server`,可以使用以下命令: > ```bash -> CUDA_VISIBLE_DEVICES=0,1 mineru-vllm-server --port 30000 --data-parallel-size 2 +> CUDA_VISIBLE_DEVICES=0,1 mineru-openai-server --engine vllm --port 30000 --data-parallel-size 2 > ``` > > - 如果您有多张显卡,需要在卡0和卡1上启动两个`fastapi`服务,并分别监听不同的端口,可以使用以下命令: From 376d1e38d5c84f919b622cc4ca5b29ee13756d53 Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 19 Nov 2025 19:43:11 +0800 Subject: [PATCH 22/66] fix: update quick_usage.md to clarify support for vllm and lmdeploy acceleration --- docs/en/usage/quick_usage.md | 16 +++++++++++----- docs/zh/usage/quick_usage.md | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/docs/en/usage/quick_usage.md b/docs/en/usage/quick_usage.md index 697e9a84..698899e0 100644 --- a/docs/en/usage/quick_usage.md +++ b/docs/en/usage/quick_usage.md @@ -29,7 +29,7 @@ mineru -p -o mineru -p -o -b vlm-transformers ``` > [!TIP] -> The vlm backend additionally supports `vllm` acceleration. Compared to the `transformers` backend, `vllm` can achieve 20-30x speedup. You can check the installation method for the complete package supporting `vllm` acceleration in the [Extension Modules Installation Guide](../quick_start/extension_modules.md). +> The vlm backend additionally supports `vllm`/`lmdeploy` acceleration. Compared to the `transformers` backend, inference speed can be significantly improved. You can check the installation method for the complete package supporting `vllm`/`lmdeploy` acceleration in the [Extension Modules Installation Guide](../quick_start/extension_modules.md). If you need to adjust parsing options through custom parameters, you can also check the more detailed [Command Line Tools Usage Instructions](./cli_tools.md) in the documentation. @@ -48,6 +48,8 @@ If you need to adjust parsing options through custom parameters, you can also ch mineru-gradio --server-name 0.0.0.0 --server-port 7860 # Or using vlm-vllm-engine/pipeline backends (requires vllm environment) mineru-gradio --server-name 0.0.0.0 --server-port 7860 --enable-vllm-engine true + # Or using vlm-lmdeploy-engine/pipeline backends (requires lmdeploy environment) + mineru-gradio --server-name 0.0.0.0 --server-port 7860 --enable-lmdeploy-engine true ``` >[!TIP] > @@ -55,8 +57,12 @@ If you need to adjust parsing options through custom parameters, you can also ch - Using `http-client/server` method: ```bash - # Start vllm server (requires vllm environment) - mineru-vllm-server --port 30000 + # Start openai compatible server (requires vllm or lmdeploy environment) + mineru-openai-server + # Or start vllm server (requires vllm environment) + mineru-openai-server --engine vllm --port 30000 + # Or start lmdeploy server (requires lmdeploy environment) + mineru-openai-server --engine lmdeploy --server-port 30000 ``` >[!TIP] >In another terminal, connect to vllm server via http client (only requires CPU and network, no vllm environment needed) @@ -65,8 +71,8 @@ If you need to adjust parsing options through custom parameters, you can also ch > ``` > [!NOTE] -> All officially supported vllm parameters can be passed to MinerU through command line arguments, including the following commands: `mineru`, `mineru-vllm-server`, `mineru-gradio`, `mineru-api`. -> We have compiled some commonly used parameters and usage methods for `vllm`, which can be found in the documentation [Advanced Command Line Parameters](./advanced_cli_parameters.md). +> All officially supported `vllm/lmdeploy` parameters can be passed to MinerU through command line arguments, including the following commands: `mineru`, `mineru-openai-server`, `mineru-gradio`, `mineru-api`. +> We have compiled some commonly used parameters and usage methods for `vllm/lmdeploy`, which can be found in the documentation [Advanced Command Line Parameters](./advanced_cli_parameters.md). ## Extending MinerU Functionality with Configuration Files diff --git a/docs/zh/usage/quick_usage.md b/docs/zh/usage/quick_usage.md index 8db90f33..97179770 100644 --- a/docs/zh/usage/quick_usage.md +++ b/docs/zh/usage/quick_usage.md @@ -28,7 +28,7 @@ mineru -p -o mineru -p -o -b vlm-transformers ``` > [!TIP] -> vlm后端另外支持`vllm`加速,与`transformers`后端相比,`vllm`的加速比可达20~30倍,可以在[扩展模块安装指南](../quick_start/extension_modules.md)中查看支持`vllm`加速的完整包安装方法。 +> vlm后端另外支持`vllm`/`lmdeploy`加速,与`transformers`后端相比,推理速度可大幅提升。可以在[扩展模块安装指南](../quick_start/extension_modules.md)中查看支持`vllm`/`lmdeploy`加速的扩展包安装方法。 如果需要通过自定义参数调整解析选项,您也可以在文档中查看更详细的[命令行工具使用说明](./cli_tools.md)。 @@ -47,6 +47,8 @@ mineru -p -o -b vlm-transformers mineru-gradio --server-name 0.0.0.0 --server-port 7860 # 或使用 vlm-vllm-engine/pipeline 后端(需安装vllm环境) mineru-gradio --server-name 0.0.0.0 --server-port 7860 --enable-vllm-engine true + # 或使用 vlm-lmdeploy-engine/pipeline 后端(需安装lmdeploy环境) + mineru-gradio --server-name 0.0.0.0 --server-port 7860 --enable-lmdeploy-engine true ``` >[!TIP] > @@ -54,8 +56,12 @@ mineru -p -o -b vlm-transformers - 使用`http-client/server`方式调用: ```bash - # 启动vllm server(需要安装vllm环境) - mineru-vllm-server --port 30000 + # 启动openai兼容服务器(需要安装vllm或lmdeploy环境) + mineru-openai-server + # 或指定vllm为推理引擎(需要安装vllm环境) + mineru-openai-server --engine vllm --port 30000 + # 或指定lmdeploy为推理引擎(需要安装lmdeploy环境) + mineru-openai-server --engine lmdeploy --server-port 30000 ``` >[!TIP] >在另一个终端中通过http client连接vllm server(只需cpu与网络,不需要vllm环境) @@ -64,8 +70,8 @@ mineru -p -o -b vlm-transformers > ``` > [!NOTE] -> 所有vllm官方支持的参数都可用通过命令行参数传递给 MinerU,包括以下命令:`mineru`、`mineru-vllm-server`、`mineru-gradio`、`mineru-api`, -> 我们整理了一些`vllm`使用中的常用参数和使用方法,可以在文档[命令行进阶参数](./advanced_cli_parameters.md)中获取。 +> 所有`vllm/lmdeploy`官方支持的参数都可用通过命令行参数传递给 MinerU,包括以下命令:`mineru`、`mineru-openai-server`、`mineru-gradio`、`mineru-api`, +> 我们整理了一些`vllm/lmdeploy`使用中的常用参数和使用方法,可以在文档[命令行进阶参数](./advanced_cli_parameters.md)中获取。 ## 基于配置文件扩展 MinerU 功能 From 33696974fe26a0c23ef4125e2b79bb1ca70df36a Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 19 Nov 2025 19:55:02 +0800 Subject: [PATCH 23/66] fix: update qwen_vl_utils version constraint and specify platform dependencies for mineru --- pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8330efd2..138cf038 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dependencies = [ "beautifulsoup4>=4.13.5,<5", "magika>=0.6.2,<1.1.0", "mineru-vl-utils>=0.1.16,<1", - "qwen_vl_utils>=0.0.14,<0.1", + "qwen_vl_utils>=0.0.14,<1", ] [project.optional-dependencies] @@ -98,7 +98,8 @@ core = [ ] all = [ "mineru[core]", - "mineru[vllm]", + "mineru[vllm] ; sys_platform == 'linux'", + "mineru[lmdeploy] ; sys_platform == 'windows'", ] [project.urls] From e7c80da6024a56d97a321c62ca8381ade5766084 Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 19 Nov 2025 20:08:50 +0800 Subject: [PATCH 24/66] fix: update Python version support details for Windows and clarify dependency limitations --- README.md | 5 +++-- README_zh-CN.md | 5 +++-- docs/en/quick_start/index.md | 6 ++++-- docs/zh/quick_start/index.md | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 87625912..b5531998 100644 --- a/README.md +++ b/README.md @@ -684,7 +684,7 @@ A WebUI developed based on Gradio, with a simple interface and only core parsing Python Version - 3.10-3.13 + 3.10-3.137 @@ -694,7 +694,8 @@ A WebUI developed based on Gradio, with a simple interface and only core parsing 3 MLX requires macOS 13.5 or later, recommended for use with version 14.0 or higher. 4 Windows vLLM support via WSL2(Windows Subsystem for Linux). 5 Windows LMDeploy can only use the `turbomind` backend, which is slightly slower than the `pytorch` backend. If performance is critical, it is recommended to run it via WSL2. -6 Servers compatible with the OpenAI API, such as local or remote model services deployed via inference frameworks like `vLLM`, `SGLang`, or `LMDeploy`. +6 Servers compatible with the OpenAI API, such as local or remote model services deployed via inference frameworks like `vLLM`, `SGLang`, or `LMDeploy`. +7 Windows + LMDeploy only supports Python versions 3.10–3.12, as the critical dependency `ray` does not yet support Python 3.13 on Windows. ### Install MinerU diff --git a/README_zh-CN.md b/README_zh-CN.md index cecc891c..b0a492a1 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -671,7 +671,7 @@ https://github.com/user-attachments/assets/4bea02c9-6d54-4cd6-97ed-dff14340982c python版本 - 3.10-3.13 + 3.10-3.137 @@ -681,7 +681,8 @@ https://github.com/user-attachments/assets/4bea02c9-6d54-4cd6-97ed-dff14340982c 3 MLX需macOS 13.5及以上版本支持,推荐14.0以上版本使用 4 Windows vLLM通过WSL2(适用于 Linux 的 Windows 子系统)实现支持 5 Windows LMDeploy只能使用`turbomind`后端,速度比`pytorch`后端稍慢,如对速度有要求建议通过WSL2运行 -6 兼容OpenAI API的服务器,如通过`vLLM`/`SGLang`/`LMDeploy`等推理框架部署的本地模型服务器或远程模型服务 +6 兼容OpenAI API的服务器,如通过`vLLM`/`SGLang`/`LMDeploy`等推理框架部署的本地模型服务器或远程模型服务 +7 Windows + LMDeploy 由于关键依赖`ray`未能在windows平台支持Python 3.13,故仅支持至3.10~3.12版本 > [!TIP] > 除以上主流环境与平台外,我们也收录了一些社区用户反馈的其他平台支持情况,详情请参考[其他加速卡适配](https://opendatalab.github.io/MinerU/zh/usage/)。 diff --git a/docs/en/quick_start/index.md b/docs/en/quick_start/index.md index 0be3b2ae..c2a94399 100644 --- a/docs/en/quick_start/index.md +++ b/docs/en/quick_start/index.md @@ -83,7 +83,7 @@ A WebUI developed based on Gradio, with a simple interface and only core parsing Python Version - 3.10-3.13 + 3.10-3.137 @@ -93,7 +93,9 @@ A WebUI developed based on Gradio, with a simple interface and only core parsing 3 MLX requires macOS 13.5 or later, recommended for use with version 14.0 or higher. 4 Windows vLLM support via WSL2(Windows Subsystem for Linux). 5 Windows LMDeploy can only use the `turbomind` backend, which is slightly slower than the `pytorch` backend. If performance is critical, it is recommended to run it via WSL2. -6 Servers compatible with the OpenAI API, such as local or remote model services deployed via inference frameworks like `vLLM`, `SGLang`, or `LMDeploy`. +6 Servers compatible with the OpenAI API, such as local or remote model services deployed via inference frameworks like `vLLM`, `SGLang`, or `LMDeploy`. +7 Windows + LMDeploy only supports Python versions 3.10–3.12, as the critical dependency `ray` does not yet support Python 3.13 on Windows. + ### Install MinerU diff --git a/docs/zh/quick_start/index.md b/docs/zh/quick_start/index.md index 657184a1..b56c0635 100644 --- a/docs/zh/quick_start/index.md +++ b/docs/zh/quick_start/index.md @@ -83,7 +83,7 @@ python版本 - 3.10-3.13 + 3.10-3.137 @@ -94,6 +94,8 @@ 4 Windows vLLM通过WSL2(适用于 Linux 的 Windows 子系统)实现支持 5 Windows LMDeploy只能使用`turbomind`后端,速度比`pytorch`后端稍慢,如对速度有要求建议通过WSL2运行 6 兼容OpenAI API的服务器,如通过`vLLM`/`SGLang`/`LMDeploy`等推理框架部署的本地模型服务器或远程模型服务 +7 Windows + LMDeploy 由于关键依赖`ray`未能在windows平台支持Python 3.13,故仅支持至3.10~3.12版本 + > [!TIP] > 除以上主流环境与平台外,我们也收录了一些社区用户反馈的其他平台支持情况,详情请参考[其他加速卡适配](https://opendatalab.github.io/MinerU/zh/usage/)。 From 38f5995ae4cbc9af7b71bc7e324d6fb5ad1c00c7 Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 19 Nov 2025 20:17:37 +0800 Subject: [PATCH 25/66] fix: clarify Dockerfile usage instructions for lmdeploy and vllm in Ascend.md --- docs/zh/usage/acceleration_cards/Ascend.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 56d66296..638eb3b8 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -11,22 +11,19 @@ docker: 20.10.12 Ascend加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: -### 2.1 使用 lmdeploy - -#### 使用 Dockerfile 构建镜像 +### 2.1 使用 Dockerfile 构建镜像 (lmdeploy) ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile docker build --network=host -t mineru:lmdeploy-latest -f npu.Dockerfile . ``` -### 2.2 使用 vllm - -#### 使用 Dockerfile 构建镜像 +### 2.2 使用 Dockerfile 构建镜像 (vllm) ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile -# 下载 Dockerfile后,使用编辑器打开并注释掉第3行的基础镜像,解除注释第5行的基础镜像后再执行后续操作 +# 将基础镜像从lmdeploy切换为vllm +sed -i '3s/^/# /' npu.Dockerfile && sed -i '5s/^# //' npu.Dockerfile docker build --network=host -t mineru:vllm-latest -f npu.Dockerfile . ``` From a01a5d798bb15795d01b33f206f94e5f53c4462d Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 15:36:43 +0800 Subject: [PATCH 26/66] fix: add environment variable for local model source in Docker usage instructions --- docs/zh/usage/acceleration_cards/Ascend.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 638eb3b8..fb9f6325 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -48,6 +48,7 @@ docker run -u root --name mineru_docker --privileged=true \ -v /usr/local/dcmi:/usr/local/dcmi \ -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \ + -e MINERU_MODEL_SOURCE=local \ -e MINERU_LMDEPLOY_DEVICE=ascend \ -it mineru:lmdeploy-latest \ /bin/bash From ed6fc3e44e029f7e857682f313fbe2c830132ccd Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 15:49:46 +0800 Subject: [PATCH 27/66] fix: correct vllm component names in Ascend.md --- docs/zh/usage/acceleration_cards/Ascend.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index fb9f6325..33f1a391 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -83,17 +83,17 @@ docker run -u root --name mineru_docker --privileged=true \ ✅ - vllm-transformers + vlm-transformers ✅ ✅ - vllm-vllm-engine + vlm-<env_name>-engine ❌ ✅ - vllm-http-client + vlm-http-client ✅ ✅ @@ -104,17 +104,17 @@ docker run -u root --name mineru_docker --privileged=true \ ✅ - vllm-transformers + vlm-transformers ✅ ✅ - vllm-vllm-async-engine + vlm-<env_name>-engine ✅ ✅ - vllm-http-client + vlm-http-client ✅ ✅ @@ -125,17 +125,17 @@ docker run -u root --name mineru_docker --privileged=true \ ✅ - vllm-transformers + vlm-transformers ✅ ✅ - vllm-vllm-async-engine + vlm-<env_name>-engine ✅ ✅ - vllm-http-client + vlm-http-client ✅ ✅ From 7bffbe2541074c78253df5c406eb942c520e810b Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 15:54:26 +0800 Subject: [PATCH 28/66] fix: correct vllm component names in Ascend.md --- docs/zh/usage/acceleration_cards/Ascend.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 33f1a391..c1e133c7 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -68,7 +68,7 @@ docker run -u root --name mineru_docker --privileged=true \ 使用场景 - 环境 + 推理引擎 vllm @@ -88,7 +88,7 @@ docker run -u root --name mineru_docker --privileged=true \ ✅ - vlm-<env_name>-engine + vlm-<engine_name>-engine ❌ ✅ @@ -109,7 +109,7 @@ docker run -u root --name mineru_docker --privileged=true \ ✅ - vlm-<env_name>-engine + vlm-<engine_name>-engine ✅ ✅ @@ -130,7 +130,7 @@ docker run -u root --name mineru_docker --privileged=true \ ✅ - vlm-<env_name>-engine + vlm-<engine_name>-engine ✅ ✅ From c884d7ddb9b6b1ced2fdc1425084934f43bb2de1 Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 16:02:42 +0800 Subject: [PATCH 29/66] fix: correct vllm component names in Ascend.md --- docs/zh/usage/acceleration_cards/Ascend.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index c1e133c7..476bd1be 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -152,3 +152,7 @@ docker run -u root --name mineru_docker --privileged=true \ +>[!NOTE] +>由于npu卡的特殊性,单次服务启动后,不支持在运行过程中切换推理后端(backend)类型(pipeline/vlm),请根据实际需求选择合适的推理后端进行使用。 +>如需切换推理后端类型,请重新启动服务。 + From eeeaca85f810a00ffc74cab71137f25177952f51 Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 16:13:57 +0800 Subject: [PATCH 30/66] fix: update notes on backend type switching for NPU cards in Ascend.md --- docs/zh/usage/acceleration_cards/Ascend.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 476bd1be..14a536af 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -153,6 +153,6 @@ docker run -u root --name mineru_docker --privileged=true \ >[!NOTE] ->由于npu卡的特殊性,单次服务启动后,不支持在运行过程中切换推理后端(backend)类型(pipeline/vlm),请根据实际需求选择合适的推理后端进行使用。 ->如需切换推理后端类型,请重新启动服务。 +>由于npu卡的特殊性,单次服务启动后,可能会在运行过程中切换推理后端(backend)类型(pipeline/vlm)时出现异常,请尽量根据实际需求选择合适的推理后端进行使用。 +>如在服务中切换推理后端类型遇到报错或异常,请重新启动服务即可。 From 997a131278613b1c87f9453bf605e5d3a723299e Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 16:17:55 +0800 Subject: [PATCH 31/66] fix: update notes on backend type switching for NPU cards in Ascend.md --- docs/zh/usage/acceleration_cards/Ascend.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 14a536af..7c04025d 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -57,7 +57,7 @@ docker run -u root --name mineru_docker --privileged=true \ >[!TIP] > 请根据实际情况选择使用`lmdeploy`或`vllm`版本的镜像,替换上述命令中的`mineru:lmdeploy-latest`为`mineru:vllm-latest`即可。 -执行该命令后,您将进入到Docker容器的交互式终端,并映射了一些端口用于可能会使用的服务,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 +执行该命令后,您将进入到Docker容器的交互式终端,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 ## 4. 注意事项 From 1c530f64f5942b9ede3a215fa473825d6eb5d241 Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 17:10:04 +0800 Subject: [PATCH 32/66] fix: enhance CUDA and NPU availability checks in utils.py --- mineru/backend/vlm/utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mineru/backend/vlm/utils.py b/mineru/backend/vlm/utils.py index 1cd3e376..bd9b1773 100644 --- a/mineru/backend/vlm/utils.py +++ b/mineru/backend/vlm/utils.py @@ -12,14 +12,16 @@ def enable_custom_logits_processors() -> bool: import torch from vllm import __version__ as vllm_version - if not torch.cuda.is_available(): + if torch.cuda.is_available(): + major, minor = torch.cuda.get_device_capability() + # 正确计算Compute Capability + compute_capability = f"{major}.{minor}" + elif torch.npu.is_available(): + compute_capability = "8.0" + else: logger.info("CUDA not available, disabling custom_logits_processors") return False - major, minor = torch.cuda.get_device_capability() - # 正确计算Compute Capability - compute_capability = f"{major}.{minor}" - # 安全地处理环境变量 vllm_use_v1_str = os.getenv('VLLM_USE_V1', "1") if vllm_use_v1_str.isdigit(): From 7196f71153cd0f8925408d09690c37d28483b3f3 Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 17:24:20 +0800 Subject: [PATCH 33/66] fix: correct package name for qwen-vl-utils in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 138cf038..74dafe30 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dependencies = [ "beautifulsoup4>=4.13.5,<5", "magika>=0.6.2,<1.1.0", "mineru-vl-utils>=0.1.16,<1", - "qwen_vl_utils>=0.0.14,<1", + "qwen-vl-utils>=0.0.14,<1", ] [project.optional-dependencies] From a83d351ccc0f7877d5dab083708082a8e424afea Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 18:46:54 +0800 Subject: [PATCH 34/66] fix: swap Dockerfile instructions for lmdeploy and vllm in Ascend.md and npu.Dockerfile --- docker/china/npu.Dockerfile | 6 +++--- docs/zh/usage/acceleration_cards/Ascend.md | 24 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docker/china/npu.Dockerfile b/docker/china/npu.Dockerfile index 73cf904a..78066ddc 100644 --- a/docker/china/npu.Dockerfile +++ b/docker/china/npu.Dockerfile @@ -1,8 +1,8 @@ # 基础镜像配置 -# Base image containing the LMDeploy inference environment, requiring ARM(AArch64) CPU + Ascend NPU. -FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ascend:mineru-a2 # Base image containing the vLLM inference environment, requiring ARM(AArch64) CPU + Ascend NPU. -# FROM quay.io/ascend/vllm-ascend:v0.11.0rc1 +FROM quay.io/ascend/vllm-ascend:v0.11.0rc1 +# Base image containing the LMDeploy inference environment, requiring ARM(AArch64) CPU + Ascend NPU. +# FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ascend:mineru-a2 # Install libgl for opencv support & Noto fonts for Chinese characters diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 7c04025d..758c4411 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -11,22 +11,22 @@ docker: 20.10.12 Ascend加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: -### 2.1 使用 Dockerfile 构建镜像 (lmdeploy) +### 2.1 使用 Dockerfile 构建镜像 (vllm) ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile -docker build --network=host -t mineru:lmdeploy-latest -f npu.Dockerfile . -``` - -### 2.2 使用 Dockerfile 构建镜像 (vllm) - -```bash -wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile -# 将基础镜像从lmdeploy切换为vllm -sed -i '3s/^/# /' npu.Dockerfile && sed -i '5s/^# //' npu.Dockerfile docker build --network=host -t mineru:vllm-latest -f npu.Dockerfile . ``` +### 2.2 使用 Dockerfile 构建镜像 (lmdeploy) + +```bash +wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile +# 将基础镜像从 vllm 切换为 lmdeploy +sed -i '3s/^/# /' npu.Dockerfile && sed -i '5s/^# //' npu.Dockerfile +docker build --network=host -t mineru:lmdeploy-latest -f npu.Dockerfile . +``` + ## 3. 启动 Docker 容器 ```bash @@ -50,12 +50,12 @@ docker run -u root --name mineru_docker --privileged=true \ -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \ -e MINERU_MODEL_SOURCE=local \ -e MINERU_LMDEPLOY_DEVICE=ascend \ - -it mineru:lmdeploy-latest \ + -it mineru:vllm-latest \ /bin/bash ``` >[!TIP] -> 请根据实际情况选择使用`lmdeploy`或`vllm`版本的镜像,替换上述命令中的`mineru:lmdeploy-latest`为`mineru:vllm-latest`即可。 +> 请根据实际情况选择使用`lmdeploy`或`vllm`版本的镜像,替换上述命令中的`mineru:vllm-latest`为`mineru:lmdeploy-latest`即可。 执行该命令后,您将进入到Docker容器的交互式终端,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 From cd1c5c5e50e4030309fa4b0a4a9bdb5c83b7f6b8 Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 23:09:54 +0800 Subject: [PATCH 35/66] fix: update ppu.Dockerfile to include vLLM base image and specific package versions --- docker/china/ppu.Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/china/ppu.Dockerfile b/docker/china/ppu.Dockerfile index a54d6584..7e868c75 100644 --- a/docker/china/ppu.Dockerfile +++ b/docker/china/ppu.Dockerfile @@ -1,5 +1,7 @@ # Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + t-head PPU. FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ppu:mineru-ppu +# Base image containing the vLLM inference environment, requiring amd64(x86-64) CPU + t-head PPU. +# FROM crpi-vofi3w62lkohhxsp.cn-shanghai.personal.cr.aliyuncs.com/opendatalab-mineru/ppu:ppu-pytorch2.6.0-ubuntu24.04-cuda12.6-vllm0.8.5-py312 # Install libgl for opencv support & Noto fonts for Chinese characters RUN apt-get update && \ @@ -14,6 +16,7 @@ RUN apt-get update && \ # Install mineru latest RUN python3 -m pip install -U 'mineru[core]' -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ + python3 -m pip install numpy==1.26.4 opencv-python==4.11.0.86 huggingface_hub==0.36.0 -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ python3 -m pip cache purge # Download models and update the configuration file From 3bcdd0a10a9ecc652b25681daae1b82e11392307 Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 23:17:59 +0800 Subject: [PATCH 36/66] fix: update Docker build tags in Ascend.md for npu images --- docs/zh/usage/acceleration_cards/Ascend.md | 10 +- docs/zh/usage/acceleration_cards/THead.md | 151 +++++++++++++++++++++ 2 files changed, 156 insertions(+), 5 deletions(-) create mode 100644 docs/zh/usage/acceleration_cards/THead.md diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 758c4411..0e7f0a40 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -15,7 +15,7 @@ Ascend加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请 ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile -docker build --network=host -t mineru:vllm-latest -f npu.Dockerfile . +docker build --network=host -t mineru:npu-vllm-latest -f npu.Dockerfile . ``` ### 2.2 使用 Dockerfile 构建镜像 (lmdeploy) @@ -24,7 +24,7 @@ docker build --network=host -t mineru:vllm-latest -f npu.Dockerfile . wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile # 将基础镜像从 vllm 切换为 lmdeploy sed -i '3s/^/# /' npu.Dockerfile && sed -i '5s/^# //' npu.Dockerfile -docker build --network=host -t mineru:lmdeploy-latest -f npu.Dockerfile . +docker build --network=host -t mineru:npu-lmdeploy-latest -f npu.Dockerfile . ``` ## 3. 启动 Docker 容器 @@ -50,12 +50,12 @@ docker run -u root --name mineru_docker --privileged=true \ -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \ -e MINERU_MODEL_SOURCE=local \ -e MINERU_LMDEPLOY_DEVICE=ascend \ - -it mineru:vllm-latest \ + -it mineru:npu-vllm-latest \ /bin/bash ``` >[!TIP] -> 请根据实际情况选择使用`lmdeploy`或`vllm`版本的镜像,替换上述命令中的`mineru:vllm-latest`为`mineru:lmdeploy-latest`即可。 +> 请根据实际情况选择使用`lmdeploy`或`vllm`版本的镜像,替换上述命令中的`mineru:npu-vllm-latest`为`mineru:npu-lmdeploy-latest`即可。 执行该命令后,您将进入到Docker容器的交互式终端,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 @@ -68,7 +68,7 @@ docker run -u root --name mineru_docker --privileged=true \ 使用场景 - 推理引擎 + 容器环境 vllm diff --git a/docs/zh/usage/acceleration_cards/THead.md b/docs/zh/usage/acceleration_cards/THead.md new file mode 100644 index 00000000..6aa6e1ae --- /dev/null +++ b/docs/zh/usage/acceleration_cards/THead.md @@ -0,0 +1,151 @@ +## 1. 测试平台 +``` +os: Ubuntu 22.04 +cpu: INTEL x86_64 +ppu: ZW810E +driver: 1.4.0 +docker: 26.1.4 +``` + +## 2. 环境准备 + +ppu加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: + +### 2.1 使用 Dockerfile 构建镜像 (lmdeploy) + +```bash +wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/ppu.Dockerfile +docker build --network=host -t mineru:ppu-lmdeploy-latest -f npu.Dockerfile . +``` + +### 2.2 使用 Dockerfile 构建镜像 (vllm) + +```bash +wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile +# 将基础镜像从lmdeploy切换为vllm +sed -i '2s/^/# /' npu.Dockerfile && sed -i '4s/^# //' npu.Dockerfile +docker build --network=host -t mineru:ppu-vllm-latest -f npu.Dockerfile . +``` + +## 3. 启动 Docker 容器 + +```bash +docker run --privileged=true \ + --name mineru_docker \ + --device=/dev/alixpu \ + --device=/dev/alixpu_ctl \ + --ipc=host \ + --network=host \ + --ulimit memlock=-1 \ + --ulimit stack=67108864 \ + --shm-size=500g \ + -v /mnt:/mnt \ + -v /datapool:/datapool \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -e MINERU_MODEL_SOURCE=local \ + -it mineru:ppu-lmdeploy-latest \ + /bin/bash +``` + +>[!TIP] +> 请根据实际情况选择使用`lmdeploy`或`vllm`版本的镜像,替换上述命令中的`mineru:ppu-lmdeploy-latest`为`mineru:ppu-vllm-latest`即可。 + +执行该命令后,您将进入到Docker容器的交互式终端,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 +您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 + +## 4. 注意事项 + +不同环境下,MinerU对ppu加速卡的支持情况如下表所示: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
使用场景容器环境
vllmlmdeploy
命令行工具(mineru)pipeline✅✅
vlm-transformers✅✅
vlm-<engine_name>-engine❌✅
vlm-http-client✅✅
fastapi服务(mineru-api)pipeline✅✅
vlm-transformers✅✅
vlm-<engine_name>-engine✅✅
vlm-http-client✅✅
gradio界面(mineru-gradio)pipeline✅✅
vlm-transformers✅✅
vlm-<engine_name>-engine✅✅
vlm-http-client✅✅
openai-server服务(mineru-openai-server)✅✅
数据并行 (--data-parallel-size/--dp)✅❌
+ +>[!NOTE] +>由于npu卡的特殊性,单次服务启动后,可能会在运行过程中切换推理后端(backend)类型(pipeline/vlm)时出现异常,请尽量根据实际需求选择合适的推理后端进行使用。 +>如在服务中切换推理后端类型遇到报错或异常,请重新启动服务即可。 + From 28ebc0e2e87ae870365d6a5326fddc3b045862e9 Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 23:21:29 +0800 Subject: [PATCH 37/66] fix: update THead.md to reference ppu.Dockerfile for building images --- docs/zh/usage/acceleration_cards/THead.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/THead.md b/docs/zh/usage/acceleration_cards/THead.md index 6aa6e1ae..63c41d11 100644 --- a/docs/zh/usage/acceleration_cards/THead.md +++ b/docs/zh/usage/acceleration_cards/THead.md @@ -15,16 +15,16 @@ ppu加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请根 ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/ppu.Dockerfile -docker build --network=host -t mineru:ppu-lmdeploy-latest -f npu.Dockerfile . +docker build --network=host -t mineru:ppu-lmdeploy-latest -f ppu.Dockerfile . ``` ### 2.2 使用 Dockerfile 构建镜像 (vllm) ```bash -wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/npu.Dockerfile +wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/ppu.Dockerfile # 将基础镜像从lmdeploy切换为vllm -sed -i '2s/^/# /' npu.Dockerfile && sed -i '4s/^# //' npu.Dockerfile -docker build --network=host -t mineru:ppu-vllm-latest -f npu.Dockerfile . +sed -i '2s/^/# /' ppu.Dockerfile && sed -i '4s/^# //' ppu.Dockerfile +docker build --network=host -t mineru:ppu-vllm-latest -f ppu.Dockerfile . ``` ## 3. 启动 Docker 容器 From 72fa59bab201c65187bd4c0b0f52484d32654810 Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 23:36:29 +0800 Subject: [PATCH 38/66] fix: update THead.md to reference ppu.Dockerfile for building images --- docker/china/ppu.Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/china/ppu.Dockerfile b/docker/china/ppu.Dockerfile index 7e868c75..ba3035e9 100644 --- a/docker/china/ppu.Dockerfile +++ b/docker/china/ppu.Dockerfile @@ -17,6 +17,7 @@ RUN apt-get update && \ # Install mineru latest RUN python3 -m pip install -U 'mineru[core]' -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ python3 -m pip install numpy==1.26.4 opencv-python==4.11.0.86 huggingface_hub==0.36.0 -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ + pip uninstall -y pynvml python3 -m pip cache purge # Download models and update the configuration file From 18ee522c7753b1f4b87e2d0acf581774bb42fd3c Mon Sep 17 00:00:00 2001 From: myhloli Date: Thu, 20 Nov 2025 23:36:43 +0800 Subject: [PATCH 39/66] fix: update THead.md to reference ppu.Dockerfile for building images --- docker/china/ppu.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/china/ppu.Dockerfile b/docker/china/ppu.Dockerfile index ba3035e9..9e22f5e4 100644 --- a/docker/china/ppu.Dockerfile +++ b/docker/china/ppu.Dockerfile @@ -17,7 +17,7 @@ RUN apt-get update && \ # Install mineru latest RUN python3 -m pip install -U 'mineru[core]' -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ python3 -m pip install numpy==1.26.4 opencv-python==4.11.0.86 huggingface_hub==0.36.0 -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ - pip uninstall -y pynvml + pip uninstall -y pynvml && \ python3 -m pip cache purge # Download models and update the configuration file From 83ad8e81a99957d0782963c1288824440d9e142f Mon Sep 17 00:00:00 2001 From: myhloli Date: Fri, 21 Nov 2025 00:38:47 +0800 Subject: [PATCH 40/66] fix: update status indicators in Ascend.md and THead.md for various components --- docker/china/ppu.Dockerfile | 1 - docs/zh/usage/acceleration_cards/Ascend.md | 62 +++++++++++---------- docs/zh/usage/acceleration_cards/THead.md | 65 +++++++++++----------- 3 files changed, 67 insertions(+), 61 deletions(-) diff --git a/docker/china/ppu.Dockerfile b/docker/china/ppu.Dockerfile index 9e22f5e4..7e868c75 100644 --- a/docker/china/ppu.Dockerfile +++ b/docker/china/ppu.Dockerfile @@ -17,7 +17,6 @@ RUN apt-get update && \ # Install mineru latest RUN python3 -m pip install -U 'mineru[core]' -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ python3 -m pip install numpy==1.26.4 opencv-python==4.11.0.86 huggingface_hub==0.36.0 -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ - pip uninstall -y pynvml && \ python3 -m pip cache purge # Download models and update the configuration file diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 0e7f0a40..94b9bdba 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -79,79 +79,85 @@ docker run -u root --name mineru_docker --privileged=true \ 命令行工具(mineru) pipeline - ✅ - ✅ + 🟢 + 🟢 vlm-transformers - ✅ - ✅ + 🟢 + 🟢 vlm-<engine_name>-engine - ❌ - ✅ + 🔴 + 🟢 vlm-http-client - ✅ - ✅ + 🟢 + 🟢 fastapi服务(mineru-api) pipeline - ✅ - ✅ + 🟢 + 🟢 vlm-transformers - ✅ - ✅ + 🟢 + 🟢 vlm-<engine_name>-engine - ✅ - ✅ + 🟢 + 🟢 vlm-http-client - ✅ - ✅ + 🟢 + 🟢 gradio界面(mineru-gradio) pipeline - ✅ - ✅ + 🟢 + 🟢 vlm-transformers - ✅ - ✅ + 🟢 + 🟢 vlm-<engine_name>-engine - ✅ - ✅ + 🟢 + 🟢 vlm-http-client - ✅ - ✅ + 🟢 + 🟢 openai-server服务(mineru-openai-server) - ✅ - ✅ + 🟢 + 🟢 数据并行 (--data-parallel-size/--dp) - ✅ - ❌ + 🟢 + 🔴 +注: +🟢: 支持 +🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常 +🟧: 支持但极度不稳定,在大多数场景下可能出现异常 +🔴: 不支持 + >[!NOTE] >由于npu卡的特殊性,单次服务启动后,可能会在运行过程中切换推理后端(backend)类型(pipeline/vlm)时出现异常,请尽量根据实际需求选择合适的推理后端进行使用。 >如在服务中切换推理后端类型遇到报错或异常,请重新启动服务即可。 diff --git a/docs/zh/usage/acceleration_cards/THead.md b/docs/zh/usage/acceleration_cards/THead.md index 63c41d11..457ddb35 100644 --- a/docs/zh/usage/acceleration_cards/THead.md +++ b/docs/zh/usage/acceleration_cards/THead.md @@ -72,80 +72,81 @@ docker run --privileged=true \ 命令行工具(mineru) pipeline - ✅ - ✅ + 🟢 + 🟢 vlm-transformers - ✅ - ✅ + 🟢 + 🟢 vlm-<engine_name>-engine - ❌ - ✅ + 🔴 + 🟡 vlm-http-client - ✅ - ✅ + 🟢 + 🟢 fastapi服务(mineru-api) pipeline - ✅ - ✅ + 🟢 + 🟢 vlm-transformers - ✅ - ✅ + 🟢 + 🟢 vlm-<engine_name>-engine - ✅ - ✅ + 🔴 + 🟡 vlm-http-client - ✅ - ✅ + 🟢 + 🟢 gradio界面(mineru-gradio) pipeline - ✅ - ✅ + 🟢 + 🟢 vlm-transformers - ✅ - ✅ + 🟢 + 🟢 vlm-<engine_name>-engine - ✅ - ✅ + 🔴 + 🟡 vlm-http-client - ✅ - ✅ + 🟢 + 🟢 openai-server服务(mineru-openai-server) - ✅ - ✅ + 🟢 + 🟢 数据并行 (--data-parallel-size/--dp) - ✅ - ❌ + 🟧 + 🔴 ->[!NOTE] ->由于npu卡的特殊性,单次服务启动后,可能会在运行过程中切换推理后端(backend)类型(pipeline/vlm)时出现异常,请尽量根据实际需求选择合适的推理后端进行使用。 ->如在服务中切换推理后端类型遇到报错或异常,请重新启动服务即可。 - +注: +🟢: 支持 +🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常 +🟧: 支持但极度不稳定,在大多数场景下可能出现异常 +🔴: 不支持 From 2111c35b839ded32fdc68635488704dacc356fd0 Mon Sep 17 00:00:00 2001 From: myhloli Date: Fri, 21 Nov 2025 00:52:15 +0800 Subject: [PATCH 41/66] feat: add Cambricon support documentation and update index for acceleration cards --- docs/zh/usage/acceleration_cards/Cambricon.md | 253 ++++++++++++++++++ docs/zh/usage/index.md | 12 +- 2 files changed, 260 insertions(+), 5 deletions(-) create mode 100644 docs/zh/usage/acceleration_cards/Cambricon.md diff --git a/docs/zh/usage/acceleration_cards/Cambricon.md b/docs/zh/usage/acceleration_cards/Cambricon.md new file mode 100644 index 00000000..1918c41c --- /dev/null +++ b/docs/zh/usage/acceleration_cards/Cambricon.md @@ -0,0 +1,253 @@ +# MinerU +## 1. 环境准备 +容器启动方式见第3节 +### 1.1 获取代码 +``` +git clone https://github.com/opendatalab/MinerU.git +git checkout fa1149cd4abf9db5e0f13e4e074cdb568be189f4 +``` +### 1.2 安装依赖 +``` +source /torch/venv3/pytorch_infer/bin/activate +pip install accelerate==1.11.0 doclayout_yolo==0.0.4 thop==0.1.1.post2209072238 ultralytics-thop==2.0.18 ultralytics==8.3.228 +# requirements_check.txt具体内容在下面 +pip install -r requirements_check.txt +cd MinerU +pip install -e .[core] --no-deps +``` +requirements_check.txt +``` +# triton==3.0.0+mlu1.3.1 +# torch==2.5.0+cpu +# torchvision==0.20.0+cpu + + +# === 1. 已安装且版本相同 === +# (这些包已满足要求, 无需操作) + + +# === 2. 已安装但版本不同 === +# (运行 pip install -r 将强制更新到左侧的目标版本) +# accelerate==1.11.0 # 0.33.0 +beautifulsoup4==4.14.2 # 4.12.3 +cffi==2.0.0 # 1.17.1 +huggingface-hub==0.36.0 # 0.25.2 +jiter==0.12.0 # 0.8.2 +openai==2.8.0 # 1.59.7 +pillow==11.3.0 # 10.4.0 +sympy==1.14.0 # 1.13.1 +tokenizers==0.22.1 # 0.21.0 +# torch==2.9.1 # 2.5.0+cpu +# torchvision==0.24.1 # 0.20.0+cpu +transformers==4.57.1 # 4.48.0 +# triton==3.5.1 # 3.0.0+mlu1.3.1 +typing-extensions==4.15.0 # 4.12.2 + +# === 3. 未安装 === +# (运行 pip install -r 将安装这些包) +aiofiles==24.1.0 +albucore==0.0.24 +albumentations==2.0.8 +antlr4-python3-runtime==4.9.3 +brotli==1.2.0 +coloredlogs==15.0.1 +colorlog==6.10.1 +cryptography==46.0.3 +# doclayout_yolo==0.0.4 +fast-langdetect==0.2.5 +fasttext-predict==0.9.2.4 +ffmpy==1.0.0 +flatbuffers==25.9.23 +ftfy==6.3.1 +gradio-client==1.13.3 +gradio-pdf==0.0.22 +gradio==5.49.1 +groovy==0.1.2 +hf-xet==1.2.0 +httpx-retries==0.4.5 +humanfriendly==10.0 +imageio==2.37.2 +json-repair==0.53.0 +magika==0.6.3 +markdown-it-py==4.0.0 +mdurl==0.1.2 +mineru-vl-utils==0.1.15 +mineru==2.6.4 +modelscope==1.31.0 +# nvidia-cublas-cu12==12.8.4.1 +# nvidia-cuda-cupti-cu12==12.8.90 +# nvidia-cuda-nvrtc-cu12==12.8.93 +# nvidia-cuda-runtime-cu12==12.8.90 +# nvidia-cudnn-cu12==9.10.2.21 +# nvidia-cufft-cu12==11.3.3.83 +# nvidia-cufile-cu12==1.13.1.3 +# nvidia-curand-cu12==10.3.9.90 +# nvidia-cusolver-cu12==11.7.3.90 +# nvidia-cusparse-cu12==12.5.8.93 +# nvidia-cusparselt-cu12==0.7.1 +# nvidia-nccl-cu12==2.27.5 +# nvidia-nvjitlink-cu12==12.8.93 +# nvidia-nvshmem-cu12==3.3.20 +# nvidia-nvtx-cu12==12.8.90 +omegaconf==2.3.0 +onnxruntime==1.23.2 +orjson==3.11.4 +pdfminer.six==20250506 +pdftext==0.6.3 +polars-runtime-32==1.35.2 +polars==1.35.2 +pyclipper==1.3.0.post6 +pydantic-settings==2.12.0 +pydub==0.25.1 +pypdf==6.2.0 +pypdfium2==4.30.0 +python-multipart==0.0.20 +reportlab==4.4.4 +rich==14.2.0 +robust-downloader==0.0.2 +ruff==0.14.5 +safehttpx==0.1.7 +scikit-image==0.25.2 +seaborn==0.13.2 +semantic-version==2.10.0 +shapely==2.1.2 +shellingham==1.5.4 +simsimd==6.5.3 +stringzilla==4.2.3 +# thop==0.1.1.post2209072238 +tifffile==2025.5.10 +typer==0.20.0 +typing-inspection==0.4.2 +# ultralytics-thop==2.0.18 +# ultralytics==8.3.228 +``` +### 1.3 修改代码 +/raid_data/home/yqk/mineru-251114/MinerU/mineru/backend/pipeline/pipeline_analyze.py, line 1 +添加代码 +``` +# 添加MLU支持 +import torch_mlu.utils.gpu_migration +# 高版本镜像为 +# import torch.mlu.utils.gpu_migration +``` + +## 2. 使用方法 +``` +export HF_ENDPOINT=https://hf-mirror.com +mineru-api --host 0.0.0.0 --port 8009 +``` + +## 3. 其他 + +### 3.1 Dify插件配置问题 +给Dify的MinerU插件使用时,需将Dify的.env文件中FILES_URL设置为http://{ip}:{dify的网页访问端口}。 +根据网上找到的很多回答可能是要暴露5001,并将FILES_URL设置为http://{ip}:5001,并暴露5001端口,但其实设置为dify的网页访问端口即可。 + +### 3.2 容器启动方式 + +``` +export MY_CONTAINER="[容器名称]" +num=`docker ps -a|grep "$MY_CONTAINER" | wc -l` +echo $num +echo $MY_CONTAINER +if [ 0 -eq $num ];then +docker run -d \ + --privileged \ + --pid=host \ + --net=host \ + --shm-size 64g \ + --device /dev/cambricon_dev0 \ + --device /dev/cambricon_ipcm0 \ + --device /dev/cambricon_ctl \ + --name $MY_CONTAINER \ + -v [/path/to/your/data:/path/to/your/data] \ + -v /usr/bin/cnmon:/usr/bin/cnmon \ + [镜像名称] \ + sleep infinity +docker exec -ti $MY_CONTAINER /bin/bash +else + docker start $MY_CONTAINER + docker exec -ti $MY_CONTAINER /bin/bash +fi +``` + +### 3.3 将上面的过程进行打包 + +准备好前面的requirements_check.txt + +Dockerfile + +``` +# 1. 使用指定的基础镜像 +FROM cambricon-base/pytorch:v25.01-torch2.5.0-torchmlu1.24.1-ubuntu22.04-py310 + +# 2. 设置环境变量 +ENV HF_ENDPOINT=https://hf-mirror.com + +# 3. 定义 venv_pip 路径以便复用 +# 基础镜像中的虚拟环境路径 +ARG VENV_PIP=/torch/venv3/pytorch_infer/bin/pip + +# 4. 设置工作目录 +WORKDIR /app + +# 5. 安装 git (基础镜像可能不包含) +RUN apt-get update && apt-get install -y git && \ + rm -rf /var/lib/apt/lists/* + +# 6. 复制 requirements_check.txt 到镜像中 +# (这个文件需要您在宿主机上和 Dockerfile 放在同一目录下) +COPY requirements_check.txt . + +# 7. 步骤 1.1 & 1.2: 获取代码并安装所有依赖 +# 在一个 RUN 层中执行所有安装,以优化镜像大小 +RUN \ + # 1.1 获取代码 + echo "Cloning MinerU repository..." && \ + git clone https://gh-proxy.org/https://github.com/opendatalab/MinerU.git && \ + cd MinerU && \ + git checkout fa1149cd4abf9db5e0f13e4e074cdb568be189f4 && \ + cd .. && \ + \ + # 1.2 安装依赖 + # 第1个pip install (来自您的步骤) + echo "Installing initial dependencies..." && \ + ${VENV_PIP} install accelerate==1.11.0 doclayout_yolo==0.0.4 thop==0.1.1.post2209072238 ultralytics-thop==2.0.18 ultralytics==8.3.228 && \ + \ + # 第2个pip install (来自 requirements_check.txt) + echo "Installing dependencies from requirements_check.txt..." && \ + # 注意:基础镜像已包含 torch 和 triton,requirements_check.txt 中的注释行会被 pip 自动忽略 + ${VENV_PIP} install -r requirements_check.txt && \ + \ + # 第3个pip install (本地安装 MinerU) + echo "Installing MinerU in editable mode..." && \ + cd MinerU && \ + ${VENV_PIP} install -e .[core] --no-deps + +# 8. 步骤 1.3: 修改代码 +# 将 MLU 支持代码添加到指定文件的开头 +RUN echo "Applying MLU patch to pipeline_analyze.py..." && \ + sed -i '1i# 添加MLU支持\nimport torch_mlu.utils.gpu_migration\n# 高版本镜像为\n# import torch.mlu.utils.gpu_migration\n' \ + /app/MinerU/mineru/backend/pipeline/pipeline_analyze.py +``` + +该镜像的启动 + +``` +docker run -d --restart=always \ + --privileged \ + --pid=host \ + --net=host \ + --shm-size 64g \ + --device /dev/cambricon_dev0 \ + --device /dev/cambricon_ipcm0 \ + --device /dev/cambricon_ctl \ + --name mineru_service \ + mineru-mlu:latest \ + /torch/venv3/pytorch_infer/bin/python /app/MinerU/mineru/cli/fast_api.py --host 0.0.0.0 --port 8009 +``` + + + + + diff --git a/docs/zh/usage/index.md b/docs/zh/usage/index.md index ca44611e..d64489b5 100644 --- a/docs/zh/usage/index.md +++ b/docs/zh/usage/index.md @@ -20,11 +20,13 @@ * [DataFlow](plugin/DataFlow.md) * [BISHENG](plugin/BISHENG.md) * [RagFlow](plugin/RagFlow.md) -- 其他加速卡适配(由社区贡献) - * [昇腾 Ascend](acceleration_cards/Ascend.md) - * [沐曦 METAX](acceleration_cards/METAX.md) [#3477](https://github.com/opendatalab/MinerU/pull/3477) - * [AMD](acceleration_cards/AMD.md) [#3662](https://github.com/opendatalab/MinerU/discussions/3662) - * [太初元碁 Tecorigin](acceleration_cards/Tecorigin.md) [#3767](https://github.com/opendatalab/MinerU/pull/3767) +- 其他加速卡适配(🚀官方支持/❤️社区贡献) + * [昇腾 Ascend](acceleration_cards/Ascend.md) 🚀 + * [平头哥 T-Head](acceleration_cards/THead.md) 🚀 + * [沐曦 METAX](acceleration_cards/METAX.md) [#3477](https://github.com/opendatalab/MinerU/pull/3477) ❤️ + * [AMD](acceleration_cards/AMD.md) [#3662](https://github.com/opendatalab/MinerU/discussions/3662) ️❤️ + * [太初元碁 Tecorigin](acceleration_cards/Tecorigin.md) [#3767](https://github.com/opendatalab/MinerU/pull/3767) ❤️ + * [寒武纪 Cambricon](acceleration_cards/Cambricon.md) [#4004](https://github.com/opendatalab/MinerU/discussions/4004) ❤️ ## 开始使用 From 9c1c9d0c8917d6f11101076bcea5f0bb6ed435f5 Mon Sep 17 00:00:00 2001 From: myhloli Date: Fri, 21 Nov 2025 01:54:01 +0800 Subject: [PATCH 42/66] fix: update status indicators in Ascend.md to reflect correct state --- docs/zh/usage/acceleration_cards/Ascend.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 94b9bdba..7ff36882 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -90,7 +90,7 @@ docker run -u root --name mineru_docker --privileged=true \ vlm-<engine_name>-engine 🔴 - 🟢 + 🟡 vlm-http-client @@ -111,7 +111,7 @@ docker run -u root --name mineru_docker --privileged=true \ vlm-<engine_name>-engine 🟢 - 🟢 + 🟡 vlm-http-client @@ -132,7 +132,7 @@ docker run -u root --name mineru_docker --privileged=true \ vlm-<engine_name>-engine 🟢 - 🟢 + 🟡 vlm-http-client From 64586d03ea4463248072c679431c79683837ad8d Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 00:15:15 +0800 Subject: [PATCH 43/66] fix: import MinerULogitsProcessor conditionally for vllm-engine and vllm-async-engine backends --- mineru/backend/vlm/vlm_analyze.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mineru/backend/vlm/vlm_analyze.py b/mineru/backend/vlm/vlm_analyze.py index 296a9766..6679f04d 100644 --- a/mineru/backend/vlm/vlm_analyze.py +++ b/mineru/backend/vlm/vlm_analyze.py @@ -97,7 +97,6 @@ class ModelSingleton: if backend == "vllm-engine": try: import vllm - from mineru_vl_utils import MinerULogitsProcessor except ImportError: raise ImportError("Please install vllm to use the vllm-engine backend.") if "gpu_memory_utilization" not in kwargs: @@ -105,6 +104,7 @@ class ModelSingleton: if "model" not in kwargs: kwargs["model"] = model_path if enable_custom_logits_processors() and ("logits_processors" not in kwargs): + from mineru_vl_utils import MinerULogitsProcessor kwargs["logits_processors"] = [MinerULogitsProcessor] # 使用kwargs为 vllm初始化参数 vllm_llm = vllm.LLM(**kwargs) @@ -112,7 +112,6 @@ class ModelSingleton: try: from vllm.engine.arg_utils import AsyncEngineArgs from vllm.v1.engine.async_llm import AsyncLLM - from mineru_vl_utils import MinerULogitsProcessor except ImportError: raise ImportError("Please install vllm to use the vllm-async-engine backend.") if "gpu_memory_utilization" not in kwargs: @@ -120,6 +119,7 @@ class ModelSingleton: if "model" not in kwargs: kwargs["model"] = model_path if enable_custom_logits_processors() and ("logits_processors" not in kwargs): + from mineru_vl_utils import MinerULogitsProcessor kwargs["logits_processors"] = [MinerULogitsProcessor] # 使用kwargs为 vllm初始化参数 vllm_async_llm = AsyncLLM.from_engine_args(AsyncEngineArgs(**kwargs)) From 7beee5be621e31efaf06540c74956b815e46c69c Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 01:22:34 +0800 Subject: [PATCH 44/66] fix: update THead.md to reflect correct status indicators for vlm-engine --- docs/zh/usage/acceleration_cards/THead.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/THead.md b/docs/zh/usage/acceleration_cards/THead.md index 457ddb35..44346bb2 100644 --- a/docs/zh/usage/acceleration_cards/THead.md +++ b/docs/zh/usage/acceleration_cards/THead.md @@ -82,7 +82,7 @@ docker run --privileged=true \ vlm-<engine_name>-engine - 🔴 + 🟢 🟡 @@ -103,7 +103,7 @@ docker run --privileged=true \ vlm-<engine_name>-engine - 🔴 + 🟢 🟡 @@ -124,7 +124,7 @@ docker run --privileged=true \ vlm-<engine_name>-engine - 🔴 + 🟢 🟡 From 9aa46e9c6c0ccdda6bbc15f4f39ba0e523314c70 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 02:04:26 +0800 Subject: [PATCH 45/66] fix: update Ascend.md and THead.md to correct the order of vllm and lmdeploy for VLM model inference --- docker/china/npu.Dockerfile | 5 +++-- docker/china/ppu.Dockerfile | 11 +++++----- docs/zh/usage/acceleration_cards/Ascend.md | 4 ++-- docs/zh/usage/acceleration_cards/THead.md | 25 +++++++++++----------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/docker/china/npu.Dockerfile b/docker/china/npu.Dockerfile index 78066ddc..2b369c9d 100644 --- a/docker/china/npu.Dockerfile +++ b/docker/china/npu.Dockerfile @@ -1,4 +1,4 @@ -# 基础镜像配置 +# 基础镜像配置 vLLM 或 LMDeploy 推理环境选择其中一个,要求 ARM(AArch64) CPU + Ascend NPU。 # Base image containing the vLLM inference environment, requiring ARM(AArch64) CPU + Ascend NPU. FROM quay.io/ascend/vllm-ascend:v0.11.0rc1 # Base image containing the LMDeploy inference environment, requiring ARM(AArch64) CPU + Ascend NPU. @@ -18,7 +18,8 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # Install mineru latest -RUN python3 -m pip install -U 'mineru[core]' -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ +RUN python3 -m pip install -U pip -i https://mirrors.aliyun.com/pypi/simple && \ + python3 -m pip install -U 'mineru[core]>=2.6.5' -i https://mirrors.aliyun.com/pypi/simple && \ python3 -m pip cache purge # Download models and update the configuration file diff --git a/docker/china/ppu.Dockerfile b/docker/china/ppu.Dockerfile index 7e868c75..2de93180 100644 --- a/docker/china/ppu.Dockerfile +++ b/docker/china/ppu.Dockerfile @@ -1,7 +1,8 @@ -# Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + t-head PPU. -FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ppu:mineru-ppu +# 基础镜像配置 vLLM 或 LMDeploy 推理环境选择其中一个,要求 amd64(x86-64) CPU + t-head PPU。 # Base image containing the vLLM inference environment, requiring amd64(x86-64) CPU + t-head PPU. -# FROM crpi-vofi3w62lkohhxsp.cn-shanghai.personal.cr.aliyuncs.com/opendatalab-mineru/ppu:ppu-pytorch2.6.0-ubuntu24.04-cuda12.6-vllm0.8.5-py312 +FROM crpi-vofi3w62lkohhxsp.cn-shanghai.personal.cr.aliyuncs.com/opendatalab-mineru/ppu:ppu-pytorch2.6.0-ubuntu24.04-cuda12.6-vllm0.8.5-py312 +# Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + t-head PPU. +# FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/ppu:mineru-ppu # Install libgl for opencv support & Noto fonts for Chinese characters RUN apt-get update && \ @@ -15,8 +16,8 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # Install mineru latest -RUN python3 -m pip install -U 'mineru[core]' -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ - python3 -m pip install numpy==1.26.4 opencv-python==4.11.0.86 huggingface_hub==0.36.0 -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ +RUN python3 -m pip install -U pip -i https://mirrors.aliyun.com/pypi/simple && \ + python3 -m pip install 'mineru[core]>=2.6.5' numpy==1.26.4 opencv-python==4.11.0.86 huggingface_hub==0.36.0 -i https://mirrors.aliyun.com/pypi/simple && \ python3 -m pip cache purge # Download models and update the configuration file diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 7ff36882..d4366d71 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -9,7 +9,7 @@ docker: 20.10.12 ## 2. 环境准备 -Ascend加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: +Ascend加速卡支持使用`vllm`或`lmdeploy`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: ### 2.1 使用 Dockerfile 构建镜像 (vllm) @@ -55,7 +55,7 @@ docker run -u root --name mineru_docker --privileged=true \ ``` >[!TIP] -> 请根据实际情况选择使用`lmdeploy`或`vllm`版本的镜像,替换上述命令中的`mineru:npu-vllm-latest`为`mineru:npu-lmdeploy-latest`即可。 +> 请根据实际情况选择使用`vllm`或`lmdeploy`版本的镜像,如需使用lmdeploy,替换上述命令中的`mineru:npu-vllm-latest`为`mineru:npu-lmdeploy-latest`即可。 执行该命令后,您将进入到Docker容器的交互式终端,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 diff --git a/docs/zh/usage/acceleration_cards/THead.md b/docs/zh/usage/acceleration_cards/THead.md index 44346bb2..72069f6e 100644 --- a/docs/zh/usage/acceleration_cards/THead.md +++ b/docs/zh/usage/acceleration_cards/THead.md @@ -9,23 +9,24 @@ docker: 26.1.4 ## 2. 环境准备 -ppu加速卡支持使用`lmdeploy`或`vllm`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: +ppu加速卡支持使用`vllm`或`lmdeploy`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: -### 2.1 使用 Dockerfile 构建镜像 (lmdeploy) +### 2.1 使用 Dockerfile 构建镜像 (vllm) ```bash wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/ppu.Dockerfile +docker build --network=host -t mineru:ppu-vllm-latest -f ppu.Dockerfile . +``` + +### 2.2 使用 Dockerfile 构建镜像 (lmdeploy) + +```bash +wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/ppu.Dockerfile +# 将基础镜像从 vllm 切换为 lmdeploy +sed -i '3s/^/# /' ppu.Dockerfile && sed -i '5s/^# //' ppu.Dockerfile docker build --network=host -t mineru:ppu-lmdeploy-latest -f ppu.Dockerfile . ``` -### 2.2 使用 Dockerfile 构建镜像 (vllm) - -```bash -wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/ppu.Dockerfile -# 将基础镜像从lmdeploy切换为vllm -sed -i '2s/^/# /' ppu.Dockerfile && sed -i '4s/^# //' ppu.Dockerfile -docker build --network=host -t mineru:ppu-vllm-latest -f ppu.Dockerfile . -``` ## 3. 启动 Docker 容器 @@ -43,12 +44,12 @@ docker run --privileged=true \ -v /datapool:/datapool \ -v /var/run/docker.sock:/var/run/docker.sock \ -e MINERU_MODEL_SOURCE=local \ - -it mineru:ppu-lmdeploy-latest \ + -it mineru:ppu-vllm-latest \ /bin/bash ``` >[!TIP] -> 请根据实际情况选择使用`lmdeploy`或`vllm`版本的镜像,替换上述命令中的`mineru:ppu-lmdeploy-latest`为`mineru:ppu-vllm-latest`即可。 +> 请根据实际情况选择使用`vllm`或`lmdeploy`版本的镜像,如需使用lmdeploy,替换上述命令中的`mineru:ppu-vllm-latest`为`mineru:ppu-lmdeploy-latest`即可。 执行该命令后,您将进入到Docker容器的交互式终端,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 From 444fd6f027a15a1a97f47a6116e59a5d9d4ea3ca Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 02:12:11 +0800 Subject: [PATCH 46/66] fix: update ppu.Dockerfile to include additional dependencies for mineru installation --- docker/china/ppu.Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/china/ppu.Dockerfile b/docker/china/ppu.Dockerfile index 2de93180..0c9c3d09 100644 --- a/docker/china/ppu.Dockerfile +++ b/docker/china/ppu.Dockerfile @@ -17,7 +17,14 @@ RUN apt-get update && \ # Install mineru latest RUN python3 -m pip install -U pip -i https://mirrors.aliyun.com/pypi/simple && \ - python3 -m pip install 'mineru[core]>=2.6.5' numpy==1.26.4 opencv-python==4.11.0.86 huggingface_hub==0.36.0 -i https://mirrors.aliyun.com/pypi/simple && \ + python3 -m pip install 'mineru[core]>=2.6.5' \ + numpy==1.26.4 \ + opencv-python==4.11.0.86 \ + huggingface_hub==0.36.0 \ + dill==0.3.6 \ + setuptools==74.1.1 \ + tokenizers==0.21.1 \ + -i https://mirrors.aliyun.com/pypi/simple && \ python3 -m pip cache purge # Download models and update the configuration file From 86b1fca74c16d0497f5df7aba4d88b9547b38539 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 02:20:25 +0800 Subject: [PATCH 47/66] fix: update Dockerfiles to improve base image configurations and dependency installations --- docker/china/maca.Dockerfile | 14 ++++++++++++-- docker/china/npu.Dockerfile | 2 +- docker/china/ppu.Dockerfile | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docker/china/maca.Dockerfile b/docker/china/maca.Dockerfile index de3c6f2c..9807de1f 100644 --- a/docker/china/maca.Dockerfile +++ b/docker/china/maca.Dockerfile @@ -1,5 +1,8 @@ +# 基础镜像配置 vLLM 或 LMDeploy 推理环境,请根据实际需要选择其中一个,要求 amd64(x86-64) CPU + metax GPU。 +# Base image containing the vLLM inference environment, requiring amd64(x86-64) CPU + metax GPU. +FROM cr.metax-tech.com/public-ai-release/maca/vllm:maca.ai3.1.0.7-torch2.6-py310-ubuntu22.04-amd64 # Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + metax GPU. -FROM +# FROM # Install libgl for opencv support & Noto fonts for Chinese characters RUN apt-get update && \ @@ -12,8 +15,15 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +# mod torchvision to be compatible with torch 2.6 +RUN mv /opt/conda/lib/python3.10/site-packages/torchvision-0.15.1+metax3.1.0.4.dist-info /opt/conda/lib/python3.10/site-packages/torchvision-0.21.0+metax3.1.0.4.dist-info + # Install mineru latest -RUN python3 -m pip install -U 'mineru[core]' -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ +RUN python3 -m pip install -U pip -i https://mirrors.aliyun.com/pypi/simple && \ + python3 -m pip install 'mineru[core]>=2.6.5' \ + numpy==1.26.4 \ + opencv-python==4.11.0.86 \ + -i https://mirrors.aliyun.com/pypi/simple && \ python3 -m pip cache purge # Download models and update the configuration file diff --git a/docker/china/npu.Dockerfile b/docker/china/npu.Dockerfile index 2b369c9d..666cc2ad 100644 --- a/docker/china/npu.Dockerfile +++ b/docker/china/npu.Dockerfile @@ -1,4 +1,4 @@ -# 基础镜像配置 vLLM 或 LMDeploy 推理环境选择其中一个,要求 ARM(AArch64) CPU + Ascend NPU。 +# 基础镜像配置 vLLM 或 LMDeploy ,请根据实际需要选择其中一个,要求 ARM(AArch64) CPU + Ascend NPU。 # Base image containing the vLLM inference environment, requiring ARM(AArch64) CPU + Ascend NPU. FROM quay.io/ascend/vllm-ascend:v0.11.0rc1 # Base image containing the LMDeploy inference environment, requiring ARM(AArch64) CPU + Ascend NPU. diff --git a/docker/china/ppu.Dockerfile b/docker/china/ppu.Dockerfile index 0c9c3d09..6ca29829 100644 --- a/docker/china/ppu.Dockerfile +++ b/docker/china/ppu.Dockerfile @@ -1,4 +1,4 @@ -# 基础镜像配置 vLLM 或 LMDeploy 推理环境选择其中一个,要求 amd64(x86-64) CPU + t-head PPU。 +# 基础镜像配置 vLLM 或 LMDeploy 推理环境,请根据实际需要选择其中一个,要求 amd64(x86-64) CPU + t-head PPU。 # Base image containing the vLLM inference environment, requiring amd64(x86-64) CPU + t-head PPU. FROM crpi-vofi3w62lkohhxsp.cn-shanghai.personal.cr.aliyuncs.com/opendatalab-mineru/ppu:ppu-pytorch2.6.0-ubuntu24.04-cuda12.6-vllm0.8.5-py312 # Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + t-head PPU. From 91df5c8bb7bbf3b1f416368b58603a41f81bd953 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 03:34:35 +0800 Subject: [PATCH 48/66] fix: update index.md and METAX.md to enhance documentation for METAX deployment and usage --- docs/zh/usage/acceleration_cards/METAX.md | 255 +++++++++++++--------- docs/zh/usage/index.md | 2 +- 2 files changed, 149 insertions(+), 108 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/METAX.md b/docs/zh/usage/acceleration_cards/METAX.md index 3b978046..ba9fff3c 100644 --- a/docs/zh/usage/acceleration_cards/METAX.md +++ b/docs/zh/usage/acceleration_cards/METAX.md @@ -1,117 +1,158 @@ -## 在C500+MACA上部署并使用Mineru - -### 获取MACA镜像,包含torch-maca,maca,sglang-maca - -镜像获取地址:https://developer.metax-tech.com/softnova/docker , -选择maca-c500-pytorch:2.33.0.6-ubuntu22.04-amd64 - -若在docker上部署镜像则需要启动GPU设备访问 -```bash -docker run --device=/dev/dri --device=/dev/mxcd.... +## 1. 测试平台 +``` +os: Ubuntu 22.04 +cpu: INTEL x86_64 +gpu: C500 +driver: 2.12.13 +docker: 28.1.1 ``` -#### 注意事项 +## 2. 环境准备 -由于此镜像默认开启TORCH_ALLOW_TF32_CUBLAS_OVERRIDE,会导致backed:vlm-transformers推理结果错误 +### 2.1 使用metax官方镜像作为基础镜像构建vllm环境镜像 + +- 1. 从metax官方仓库拉取基础镜像 + - 1.1 镜像获取地址:https://developer.metax-tech.com/softnova/docker + - 1.2 在镜像网站选择`AI`分类,软件包类型选择`vllm`,操作系统选择`ubuntu` + - 1.3 找到`vllm:maca.ai3.1.0.7-torch2.6-py310-ubuntu22.04-amd64`镜像,复制拉取命令并在本地终端执行 +- 2. 使用 Dockerfile 构建镜像 (vllm) + ```bash + wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/maca.Dockerfile + docker build --network=host -t mineru:maca-vllm-latest -f maca.Dockerfile . + ``` + +### 2.2 使用 Dockerfile 构建镜像 (lmdeploy) ```bash -unset TORCH_ALLOW_TF32_CUBLAS_OVERRIDE +wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/maca.Dockerfile +# 将基础镜像从 vllm 切换为 lmdeploy +sed -i '3s/^/# /' maca.Dockerfile && sed -i '5s/^# //' maca.Dockerfile +docker build --network=host -t mineru:maca-lmdeploy-latest -f maca.Dockerfile . ``` -### 安装MinerU - -使用--no-deps,去除对一些cuda版本包的依赖,后续采用pip install-r requirements.txt 安装其他依赖 -```bash -pip install -U "mineru[core]" --no-deps -``` - -```tex -boto3>=1.28.43 -click>=8.1.7 -loguru>=0.7.2 -numpy==1.26.4 -pdfminer.six==20250506 -tqdm>=4.67.1 -requests -httpx -pillow>=11.0.0 -pypdfium2>=4.30.0 -pypdf>=5.6.0 -reportlab -pdftext>=0.6.2 -modelscope>=1.26.0 -huggingface-hub>=0.32.4 -json-repair>=0.46.2 -opencv-python>=4.11.0.86 -fast-langdetect>=0.2.3,<0.3.0 -transformers>=4.51.1 -accelerate>=1.5.1 -pydantic -matplotlib>=3.10,<4 -ultralytics>=8.3.48,<9 -dill>=0.3.8,<1 -rapid_table>=1.0.5,<2.0.0 -PyYAML>=6.0.2,<7 -ftfy>=6.3.1,<7 -openai>=1.70.0,<2 -shapely>=2.0.7,<3 -pyclipper>=1.3.0,<2 -omegaconf>=2.3.0,<3 -transformers>=4.49.0,!=4.51.0,<5.0.0 -fastapi -python-multipart -uvicorn -gradio>=5.34,<6 -gradio-pdf>=0.0.22 -albumentations -beautifulsoup4 -scikit-image==0.25.0 -outlines==0.1.11 -magika>=0.6.2,<0.7.0 -mineru-vl-utils>=0.1.6,<1 -``` -上述内容保存为requirments.txt,进行安装 -```bash -pip install -r requirments.txt -``` -安装doclayout_yolo,这里doclayout_yolo会依赖torch-cuda,使用--no-deps -```bash -pip install doclayout-yolo --no-deps -``` -### 在线使用 -**基础使用命令为:mineru -p -o -b vlm-transformers** - -- ``: Local PDF/image file or directory -- ``: Output directory -- -b --backend [pipeline|vlm-transformers|vlm-vllm-engine|vlm-http-client] (default:pipeline)
- -其他详细使用命令可参考官方文档[Quick Usage - MinerU](https://opendatalab.github.io/MinerU/usage/quick_usage/#quick-model-source-configuration) - -### 离线使用 - -**所用模型为本地模型,需要设置环境变量和config配置文件**
-#### 下载模型到本地 -通过mineru交互式命令行工具进行下载,下载完后会自动更新mineru.json配置文件 -```bash -mineru-models-download -``` -也可以在[HuggingFace](http://www.huggingface.co.)或[ModelScope](https://www.modelscope.cn/home)找到所需模型源(PDF-Extract-Kit-1.0和MinerU2.5-2509-1.2B)进行下载, -下载完成后,创建mineru.json文件,按如下进行修改 -```json -{ - "models-dir": { - "pipeline": "/path/pdf-extract-kit-1.0/", - "vlm": "/path/MinerU2.5-2509-1.2B" - }, - "config_version": "1.3.0" -} -``` -path为本地模型的存储路径,其中models-dir为本地模型的路径,pipeline代表backend为pipeline时,所需要的模型路径,vlm代表backend为vlm-开头,所需要的模型路径 - -#### 修改环境变量 +## 3. 启动 Docker 容器 ```bash -export MINERU_MODEL_SOURCE=local -export MINERU_TOOLS_CONFIG_JSON=/path/mineru.json //此环境变量为配置文件的路径 +docker run --ipc host \ + --cap-add SYS_PTRACE \ + --privileged=true \ + --device=/dev/mem \ + --device=/dev/dri \ + --device=/dev/mxcd \ + --device=/dev/infiniband \ + --group-add video \ + --network=host \ + --shm-size '100gb' \ + --ulimit memlock=-1 \ + --security-opt seccomp=unconfined \ + --security-opt apparmor=unconfined \ + --name mineru_docker \ + -v /datapool:/datapool \ + -e MINERU_MODEL_SOURCE=local \ + -it mineru:maca-vllm-latest \ + /bin/bash ``` -修改完成后即可正常使用
\ No newline at end of file + +>[!TIP] +> 请根据实际情况选择使用`vllm`或`lmdeploy`版本的镜像,如需使用lmdeploy,替换上述命令中的`mineru:maca-vllm-latest`为`mineru:maca-lmdeploy-latest`即可。 + +执行该命令后,您将进入到Docker容器的交互式终端,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。 +您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。 + +## 4. 注意事项 + +不同环境下,MinerU对ppu加速卡的支持情况如下表所示: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
使用场景容器环境
vllmlmdeploy
命令行工具(mineru)pipeline🟢🟢
vlm-transformers🟢🟢
vlm-<engine_name>-engine🟢🟡
vlm-http-client🟢🟢
fastapi服务(mineru-api)pipeline🟢🟢
vlm-transformers🟢🟢
vlm-<engine_name>-engine🟢🟡
vlm-http-client🟢🟢
gradio界面(mineru-gradio)pipeline🟢🟢
vlm-transformers🟢🟢
vlm-<engine_name>-engine🟢🟡
vlm-http-client🟢🟢
openai-server服务(mineru-openai-server)🟢🟢
数据并行 (--data-parallel-size/--dp)🔴🔴
+ +注: +🟢: 支持 +🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常 +🟧: 支持但极度不稳定,在大多数场景下可能出现异常 +🔴: 不支持 diff --git a/docs/zh/usage/index.md b/docs/zh/usage/index.md index d64489b5..944b5f8e 100644 --- a/docs/zh/usage/index.md +++ b/docs/zh/usage/index.md @@ -23,7 +23,7 @@ - 其他加速卡适配(🚀官方支持/❤️社区贡献) * [昇腾 Ascend](acceleration_cards/Ascend.md) 🚀 * [平头哥 T-Head](acceleration_cards/THead.md) 🚀 - * [沐曦 METAX](acceleration_cards/METAX.md) [#3477](https://github.com/opendatalab/MinerU/pull/3477) ❤️ + * [沐曦 METAX](acceleration_cards/METAX.md) 🚀 * [AMD](acceleration_cards/AMD.md) [#3662](https://github.com/opendatalab/MinerU/discussions/3662) ️❤️ * [太初元碁 Tecorigin](acceleration_cards/Tecorigin.md) [#3767](https://github.com/opendatalab/MinerU/pull/3767) ❤️ * [寒武纪 Cambricon](acceleration_cards/Cambricon.md) [#4004](https://github.com/opendatalab/MinerU/discussions/4004) ❤️ From 16f167b3517c6329953a6e405a3f11a703cceb55 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 14:50:27 +0800 Subject: [PATCH 49/66] fix: update transformers version constraint in pyproject.toml for compatibility --- docker/china/camb.Dockerfile | 23 ----------------------- pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 docker/china/camb.Dockerfile diff --git a/docker/china/camb.Dockerfile b/docker/china/camb.Dockerfile deleted file mode 100644 index 52239cc6..00000000 --- a/docker/china/camb.Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -# Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + cambricon MLU. -FROM - -# Install libgl for opencv support & Noto fonts for Chinese characters -RUN apt-get update && \ - apt-get install -y \ - fonts-noto-core \ - fonts-noto-cjk \ - fontconfig \ - libgl1 && \ - fc-cache -fv && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# Install mineru latest -RUN python3 -m pip install -U 'mineru[core]' -i https://mirrors.aliyun.com/pypi/simple --break-system-packages && \ - python3 -m pip cache purge - -# Download models and update the configuration file -RUN /bin/bash -c "mineru-models-download -s modelscope -m all" - -# Set the entry point to activate the virtual environment and run the command line tool -ENTRYPOINT ["/bin/bash", "-c", "export MINERU_MODEL_SOURCE=local && exec \"$@\"", "--"] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 74dafe30..a91ee104 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ test = [ ] vlm = [ "torch>=2.6.0,<3", - "transformers>=4.51.1,<5.0.0", + "transformers>=4.51.1,<4.57.2", "accelerate>=1.5.1", ] vllm = [ From 34c46cb83d75874032caaf49af6702be0052a1b7 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 15:43:30 +0800 Subject: [PATCH 50/66] fix: disable cuDNN for MACA device in common.py to improve compatibility --- mineru/cli/common.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mineru/cli/common.py b/mineru/cli/common.py index 27dcbad5..3989c7eb 100644 --- a/mineru/cli/common.py +++ b/mineru/cli/common.py @@ -18,6 +18,11 @@ from mineru.backend.vlm.vlm_analyze import doc_analyze as vlm_doc_analyze from mineru.backend.vlm.vlm_analyze import aio_doc_analyze as aio_vlm_doc_analyze from mineru.utils.pdf_page_id import get_end_page_id +if os.getenv("MINERU_LMDEPLOY_DEVICE", "") == "maca": + import torch + torch.backends.cudnn.enabled = False + + pdf_suffixes = ["pdf"] image_suffixes = ["png", "jpeg", "jp2", "webp", "gif", "bmp", "jpg", "tiff"] From 48ed75d935de68153a63ec9d4bc07b7663ba3157 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 16:00:33 +0800 Subject: [PATCH 51/66] fix: update torchvision version in maca.Dockerfile for compatibility --- docker/china/maca.Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/china/maca.Dockerfile b/docker/china/maca.Dockerfile index 9807de1f..91f60f9c 100644 --- a/docker/china/maca.Dockerfile +++ b/docker/china/maca.Dockerfile @@ -2,7 +2,7 @@ # Base image containing the vLLM inference environment, requiring amd64(x86-64) CPU + metax GPU. FROM cr.metax-tech.com/public-ai-release/maca/vllm:maca.ai3.1.0.7-torch2.6-py310-ubuntu22.04-amd64 # Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + metax GPU. -# FROM +# FROM crpi-4crprmm5baj1v8iv.cn-hang # Install libgl for opencv support & Noto fonts for Chinese characters RUN apt-get update && \ @@ -16,7 +16,8 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # mod torchvision to be compatible with torch 2.6 -RUN mv /opt/conda/lib/python3.10/site-packages/torchvision-0.15.1+metax3.1.0.4.dist-info /opt/conda/lib/python3.10/site-packages/torchvision-0.21.0+metax3.1.0.4.dist-info +RUN sed -i '3s/^Version: 0.15.1+metax3\.1\.0\.4$/Version: 0.21.0+metax3.1.0.4/' /opt/conda/lib/python3.10/site-packages/torchvision-0.15.1+metax3.1.0.4.dist-info/METADATA && \ + mv /opt/conda/lib/python3.10/site-packages/torchvision-0.15.1+metax3.1.0.4.dist-info /opt/conda/lib/python3.10/site-packages/torchvision-0.21.0+metax3.1.0.4.dist-info # Install mineru latest RUN python3 -m pip install -U pip -i https://mirrors.aliyun.com/pypi/simple && \ From 0e2e12ca8458ce7125acb8e8e49a69b083d7a839 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 16:01:10 +0800 Subject: [PATCH 52/66] fix: add MINERU_LMDEPLOY_DEVICE environment variable for MACA in METAX.md --- docs/zh/usage/acceleration_cards/METAX.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/zh/usage/acceleration_cards/METAX.md b/docs/zh/usage/acceleration_cards/METAX.md index ba9fff3c..5605e001 100644 --- a/docs/zh/usage/acceleration_cards/METAX.md +++ b/docs/zh/usage/acceleration_cards/METAX.md @@ -49,6 +49,7 @@ docker run --ipc host \ --name mineru_docker \ -v /datapool:/datapool \ -e MINERU_MODEL_SOURCE=local \ + -e MINERU_LMDEPLOY_DEVICE=maca \ -it mineru:maca-vllm-latest \ /bin/bash ``` From 4a081c32140f52ead05a02f2414ed83b2a9ae3fb Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 17:16:48 +0800 Subject: [PATCH 53/66] fix: update stability indicators and descriptions in Ascend.md, METAX.md, and THead.md for clarity --- docs/zh/usage/acceleration_cards/Ascend.md | 8 ++++---- docs/zh/usage/acceleration_cards/METAX.md | 20 ++++++++++---------- docs/zh/usage/acceleration_cards/THead.md | 8 ++++---- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index d4366d71..c5cb6749 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -153,10 +153,10 @@ docker run -u root --name mineru_docker --privileged=true \ 注: -🟢: 支持 -🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常 -🟧: 支持但极度不稳定,在大多数场景下可能出现异常 -🔴: 不支持 +🟢: 支持,运行较稳定,精度与Nvidia GPU相对一致 +🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常,或精度略有差异 +🟧: 支持但极度不稳定,在大多数场景下可能出现异常,或精度存在较大差异 +🔴: 不支持,无法运行 >[!NOTE] >由于npu卡的特殊性,单次服务启动后,可能会在运行过程中切换推理后端(backend)类型(pipeline/vlm)时出现异常,请尽量根据实际需求选择合适的推理后端进行使用。 diff --git a/docs/zh/usage/acceleration_cards/METAX.md b/docs/zh/usage/acceleration_cards/METAX.md index 5605e001..157e8554 100644 --- a/docs/zh/usage/acceleration_cards/METAX.md +++ b/docs/zh/usage/acceleration_cards/METAX.md @@ -84,8 +84,8 @@ docker run --ipc host \ vlm-transformers - 🟢 - 🟢 + 🟡 + 🟡 vlm-<engine_name>-engine @@ -105,8 +105,8 @@ docker run --ipc host \ vlm-transformers - 🟢 - 🟢 + 🟡 + 🟡 vlm-<engine_name>-engine @@ -126,8 +126,8 @@ docker run --ipc host \ vlm-transformers - 🟢 - 🟢 + 🟡 + 🟡 vlm-<engine_name>-engine @@ -153,7 +153,7 @@ docker run --ipc host \ 注: -🟢: 支持 -🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常 -🟧: 支持但极度不稳定,在大多数场景下可能出现异常 -🔴: 不支持 +🟢: 支持,运行较稳定,精度与Nvidia GPU相对一致 +🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常,或精度略有差异 +🟧: 支持但极度不稳定,在大多数场景下可能出现异常,或精度存在较大差异 +🔴: 不支持,无法运行 diff --git a/docs/zh/usage/acceleration_cards/THead.md b/docs/zh/usage/acceleration_cards/THead.md index 72069f6e..c975e538 100644 --- a/docs/zh/usage/acceleration_cards/THead.md +++ b/docs/zh/usage/acceleration_cards/THead.md @@ -147,7 +147,7 @@ docker run --privileged=true \ 注: -🟢: 支持 -🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常 -🟧: 支持但极度不稳定,在大多数场景下可能出现异常 -🔴: 不支持 +🟢: 支持,运行较稳定,精度与Nvidia GPU相对一致 +🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常,或精度略有差异 +🟧: 支持但极度不稳定,在大多数场景下可能出现异常,或精度存在较大差异 +🔴: 不支持,无法运行 From b4f725258dc7ce575821ee4fed2ccd753b48d581 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 17:42:46 +0800 Subject: [PATCH 54/66] fix: update MACA Dockerfile and METAX.md for improved clarity and support --- docker/china/maca.Dockerfile | 2 +- docs/zh/usage/acceleration_cards/METAX.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/china/maca.Dockerfile b/docker/china/maca.Dockerfile index 91f60f9c..9801cbf0 100644 --- a/docker/china/maca.Dockerfile +++ b/docker/china/maca.Dockerfile @@ -2,7 +2,7 @@ # Base image containing the vLLM inference environment, requiring amd64(x86-64) CPU + metax GPU. FROM cr.metax-tech.com/public-ai-release/maca/vllm:maca.ai3.1.0.7-torch2.6-py310-ubuntu22.04-amd64 # Base image containing the LMDeploy inference environment, requiring amd64(x86-64) CPU + metax GPU. -# FROM crpi-4crprmm5baj1v8iv.cn-hang +# FROM crpi-vofi3w62lkohhxsp.cn-shanghai.personal.cr.aliyuncs.com/opendatalab-mineru/maca:maca.ai3.1.0.7-torch2.6-py310-ubuntu22.04-lmdeploy0.10.2-amd64 # Install libgl for opencv support & Noto fonts for Chinese characters RUN apt-get update && \ diff --git a/docs/zh/usage/acceleration_cards/METAX.md b/docs/zh/usage/acceleration_cards/METAX.md index 157e8554..a98f8521 100644 --- a/docs/zh/usage/acceleration_cards/METAX.md +++ b/docs/zh/usage/acceleration_cards/METAX.md @@ -9,6 +9,8 @@ docker: 28.1.1 ## 2. 环境准备 +maca加速卡支持使用`vllm`或`lmdeploy`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: + ### 2.1 使用metax官方镜像作为基础镜像构建vllm环境镜像 - 1. 从metax官方仓库拉取基础镜像 From 35d5ba8b8fb9e22ef86cb28e7551c45613230f0a Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 18:38:34 +0800 Subject: [PATCH 55/66] fix: update maca.Dockerfile to use absolute paths for Python and mineru commands --- docker/china/maca.Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docker/china/maca.Dockerfile b/docker/china/maca.Dockerfile index 9801cbf0..1ee55066 100644 --- a/docker/china/maca.Dockerfile +++ b/docker/china/maca.Dockerfile @@ -20,15 +20,15 @@ RUN sed -i '3s/^Version: 0.15.1+metax3\.1\.0\.4$/Version: 0.21.0+metax3.1.0.4/' mv /opt/conda/lib/python3.10/site-packages/torchvision-0.15.1+metax3.1.0.4.dist-info /opt/conda/lib/python3.10/site-packages/torchvision-0.21.0+metax3.1.0.4.dist-info # Install mineru latest -RUN python3 -m pip install -U pip -i https://mirrors.aliyun.com/pypi/simple && \ - python3 -m pip install 'mineru[core]>=2.6.5' \ - numpy==1.26.4 \ - opencv-python==4.11.0.86 \ - -i https://mirrors.aliyun.com/pypi/simple && \ - python3 -m pip cache purge +RUN /opt/conda/bin/python3 -m pip install -U pip -i https://mirrors.aliyun.com/pypi/simple && \ + /opt/conda/bin/python3 -m pip install 'mineru[core]>=2.6.5' \ + numpy==1.26.4 \ + opencv-python==4.11.0.86 \ + -i https://mirrors.aliyun.com/pypi/simple && \ + /opt/conda/bin/python3 -m pip cache purge # Download models and update the configuration file -RUN /bin/bash -c "mineru-models-download -s modelscope -m all" +RUN /bin/bash -c "/opt/conda/bin/mineru-models-download -s modelscope -m all" # Set the entry point to activate the virtual environment and run the command line tool ENTRYPOINT ["/bin/bash", "-c", "export MINERU_MODEL_SOURCE=local && exec \"$@\"", "--"] \ No newline at end of file From 424c37984b0df6a6c3a0a0734fe77bea9db029d0 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 18:41:18 +0800 Subject: [PATCH 56/66] fix: add note formatting for VLM model inference support in Ascend.md, METAX.md, and THead.md --- docs/zh/usage/acceleration_cards/Ascend.md | 3 ++- docs/zh/usage/acceleration_cards/METAX.md | 3 ++- docs/zh/usage/acceleration_cards/THead.md | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index c5cb6749..7fa2ef3a 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -9,7 +9,8 @@ docker: 20.10.12 ## 2. 环境准备 -Ascend加速卡支持使用`vllm`或`lmdeploy`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: +>[!NOTE] +>Ascend加速卡支持使用`vllm`或`lmdeploy`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: ### 2.1 使用 Dockerfile 构建镜像 (vllm) diff --git a/docs/zh/usage/acceleration_cards/METAX.md b/docs/zh/usage/acceleration_cards/METAX.md index a98f8521..7397fc97 100644 --- a/docs/zh/usage/acceleration_cards/METAX.md +++ b/docs/zh/usage/acceleration_cards/METAX.md @@ -9,7 +9,8 @@ docker: 28.1.1 ## 2. 环境准备 -maca加速卡支持使用`vllm`或`lmdeploy`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: +>[!NOTE] +>maca加速卡支持使用`vllm`或`lmdeploy`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: ### 2.1 使用metax官方镜像作为基础镜像构建vllm环境镜像 diff --git a/docs/zh/usage/acceleration_cards/THead.md b/docs/zh/usage/acceleration_cards/THead.md index c975e538..bf693ffc 100644 --- a/docs/zh/usage/acceleration_cards/THead.md +++ b/docs/zh/usage/acceleration_cards/THead.md @@ -9,7 +9,8 @@ docker: 26.1.4 ## 2. 环境准备 -ppu加速卡支持使用`vllm`或`lmdeploy`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: +>[!NOTE] +>ppu加速卡支持使用`vllm`或`lmdeploy`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一: ### 2.1 使用 Dockerfile 构建镜像 (vllm) From 08c9fadbcb98fddbfb655bbbf26039a9a64fa698 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 19:18:36 +0800 Subject: [PATCH 57/66] fix: update lmdeploy version range in pyproject.toml for compatibility --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a91ee104..fcb0dc56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ vllm = [ "vllm>=0.10.1.1,<0.12", ] lmdeploy = [ - "lmdeploy>=0.10.2,<0.11", + "lmdeploy>=0.10.2,<0.12", ] mlx = [ "mlx-vlm>=0.3.3,<0.4", From b7a209a4a78d4ef28c4975ae8f8fe7d1dc1ee298 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 19:51:55 +0800 Subject: [PATCH 58/66] fix: add usage tips for NPU and MACA acceleration cards in Ascend.md, METAX.md, and THead.md --- docs/zh/usage/acceleration_cards/Ascend.md | 2 ++ docs/zh/usage/acceleration_cards/METAX.md | 3 +++ docs/zh/usage/acceleration_cards/THead.md | 3 +++ 3 files changed, 8 insertions(+) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 7fa2ef3a..69fdfabd 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -163,3 +163,5 @@ docker run -u root --name mineru_docker --privileged=true \ >由于npu卡的特殊性,单次服务启动后,可能会在运行过程中切换推理后端(backend)类型(pipeline/vlm)时出现异常,请尽量根据实际需求选择合适的推理后端进行使用。 >如在服务中切换推理后端类型遇到报错或异常,请重新启动服务即可。 +>[!TIP] +>NPU加速卡指定可用加速卡的方式与NVIDIA GPU类似,请参考[ASCEND_RT_VISIBLE_DEVICES](https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/850alpha001/maintenref/envvar/envref_07_0028.html) \ No newline at end of file diff --git a/docs/zh/usage/acceleration_cards/METAX.md b/docs/zh/usage/acceleration_cards/METAX.md index 7397fc97..9a497bb7 100644 --- a/docs/zh/usage/acceleration_cards/METAX.md +++ b/docs/zh/usage/acceleration_cards/METAX.md @@ -160,3 +160,6 @@ docker run --ipc host \ 🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常,或精度略有差异 🟧: 支持但极度不稳定,在大多数场景下可能出现异常,或精度存在较大差异 🔴: 不支持,无法运行 + +>[!TIP] +>MACA加速卡指定可用加速卡的方式与NVIDIA GPU类似,请参考[使用指定GPU设备](https://opendatalab.github.io/MinerU/zh/usage/advanced_cli_parameters/#cuda_visible_devices)章节说明。 \ No newline at end of file diff --git a/docs/zh/usage/acceleration_cards/THead.md b/docs/zh/usage/acceleration_cards/THead.md index bf693ffc..fcf8b095 100644 --- a/docs/zh/usage/acceleration_cards/THead.md +++ b/docs/zh/usage/acceleration_cards/THead.md @@ -152,3 +152,6 @@ docker run --privileged=true \ 🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常,或精度略有差异 🟧: 支持但极度不稳定,在大多数场景下可能出现异常,或精度存在较大差异 🔴: 不支持,无法运行 + +>[!TIP] +>PPU加速卡指定可用加速卡的方式与NVIDIA GPU类似,请参考[使用指定GPU设备](https://opendatalab.github.io/MinerU/zh/usage/advanced_cli_parameters/#cuda_visible_devices)章节说明。 \ No newline at end of file From 0d2bebd8b1541bd6399dda6e11072843041a6c75 Mon Sep 17 00:00:00 2001 From: myhloli Date: Tue, 25 Nov 2025 20:33:52 +0800 Subject: [PATCH 59/66] fix: add support for vlm-lmdeploy-engine and enhance compatibility with domestic acceleration platforms in README files --- README.md | 3 +++ README_zh-CN.md | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index b5531998..d623944d 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,9 @@ # Changelog +- 2025/11/26 2.6.5 Release + - Added support for a new backend vlm-lmdeploy-engine. Its usage is similar to vlm-vllm-(async)engine, but it uses lmdeploy as the inference engine and additionally supports native inference acceleration on Windows platforms compared to vllm. + - 2025/11/04 2.6.4 Release - Added timeout configuration for PDF image rendering, default is 300 seconds, can be configured via environment variable `MINERU_PDF_RENDER_TIMEOUT` to prevent long blocking of the rendering process caused by some abnormal PDF files. - Added CPU thread count configuration options for ONNX models, default is the system CPU core count, can be configured via environment variables `MINERU_INTRA_OP_NUM_THREADS` and `MINERU_INTER_OP_NUM_THREADS` to reduce CPU resource contention conflicts in high concurrency scenarios. diff --git a/README_zh-CN.md b/README_zh-CN.md index b0a492a1..2008b58c 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -44,6 +44,13 @@ # 更新记录 + +- 2025/11/26 2.6.5 发布 + - 增加新后端`vlm-lmdeploy-engine`支持,使用方式与`vlm-vllm-(async)engine`类似,但使用`lmdeploy`作为推理引擎,相比`vllm`额外支持Windows平台原生推理加速。 + - 新增国产算力平台`昇腾/npu`、`平头哥/ppu`、`沐曦/maca`的适配支持,用户可在对应平台上使用`pipeline`与`vlm`模型,并使用`vllm`/`lmdeploy`引擎加速vlm模型推理,具体使用方式请参考[其他加速卡适配](https://opendatalab.github.io/MinerU/zh/usage/)。 + - 国产平台适配不易,我们已尽量确保适配的完整性和稳定性,但仍可能存在一些稳定性/兼容问题与精度对齐问题,请大家根据适配文档页面内红绿灯情况自行选择合适的环境与场景进行使用。 + - 如在使用过程中遇到任何文档未提及的问题,为了其他用户查找解决方案,欢迎在discussions的[指定帖子](https://github.com/opendatalab/MinerU/discussions/4053)中进行反馈。 + - 2025/11/04 2.6.4 发布 - 为pdf渲染图片增加超时配置,默认为300秒,可通过环境变量`MINERU_PDF_RENDER_TIMEOUT`进行配置,防止部分异常pdf文件导致渲染过程长时间阻塞。 - 为onnx模型增加cpu线程数配置选项,默认为系统cpu核心数,可通过环境变量`MINERU_INTRA_OP_NUM_THREADS`和`MINERU_INTER_OP_NUM_THREADS`进行配置,以减少高并发场景下的对cpu资源的抢占冲突。 From a6f4eb37274796dd0edc2e41e2805233681d1e03 Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 26 Nov 2025 00:08:22 +0800 Subject: [PATCH 60/66] fix: update mineru-vl-utils version and adjust transformers constraint in pyproject.toml; enhance support note for vlm-lmdeploy-engine in README_zh-CN.md --- README_zh-CN.md | 2 +- pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README_zh-CN.md b/README_zh-CN.md index 2008b58c..2f0023ed 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -46,7 +46,7 @@ # 更新记录 - 2025/11/26 2.6.5 发布 - - 增加新后端`vlm-lmdeploy-engine`支持,使用方式与`vlm-vllm-(async)engine`类似,但使用`lmdeploy`作为推理引擎,相比`vllm`额外支持Windows平台原生推理加速。 + - 增加新后端`vlm-lmdeploy-engine`支持,使用方式与`vlm-vllm-(async)engine`类似,但使用`lmdeploy`作为推理引擎,与`vllm`相比额外支持Windows平台原生推理加速。 - 新增国产算力平台`昇腾/npu`、`平头哥/ppu`、`沐曦/maca`的适配支持,用户可在对应平台上使用`pipeline`与`vlm`模型,并使用`vllm`/`lmdeploy`引擎加速vlm模型推理,具体使用方式请参考[其他加速卡适配](https://opendatalab.github.io/MinerU/zh/usage/)。 - 国产平台适配不易,我们已尽量确保适配的完整性和稳定性,但仍可能存在一些稳定性/兼容问题与精度对齐问题,请大家根据适配文档页面内红绿灯情况自行选择合适的环境与场景进行使用。 - 如在使用过程中遇到任何文档未提及的问题,为了其他用户查找解决方案,欢迎在discussions的[指定帖子](https://github.com/opendatalab/MinerU/discussions/4053)中进行反馈。 diff --git a/pyproject.toml b/pyproject.toml index fcb0dc56..388e26a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ dependencies = [ "openai>=1.70.0,<3", "beautifulsoup4>=4.13.5,<5", "magika>=0.6.2,<1.1.0", - "mineru-vl-utils>=0.1.16,<1", + "mineru-vl-utils>=0.1.17,<1", "qwen-vl-utils>=0.0.14,<1", ] @@ -53,7 +53,7 @@ test = [ ] vlm = [ "torch>=2.6.0,<3", - "transformers>=4.51.1,<4.57.2", + "transformers>=4.51.1,!=4.57.2,<5.0.0", "accelerate>=1.5.1", ] vllm = [ From 7e33501cd0e6f7edcc598f45a9ac5e8e5c2bb991 Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 26 Nov 2025 00:15:33 +0800 Subject: [PATCH 61/66] fix: update engine support indicators in Ascend.md, METAX.md, and THead.md for clarity and consistency --- docs/zh/usage/acceleration_cards/Ascend.md | 13 ++++++------- docs/zh/usage/acceleration_cards/METAX.md | 13 ++++++------- docs/zh/usage/acceleration_cards/THead.md | 15 +++++++-------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index 69fdfabd..bf23d376 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -91,7 +91,7 @@ docker run -u root --name mineru_docker --privileged=true \ vlm-<engine_name>-engine 🔴 - 🟡 + 🟢 vlm-http-client @@ -112,7 +112,7 @@ docker run -u root --name mineru_docker --privileged=true \ vlm-<engine_name>-engine 🟢 - 🟡 + 🟢 vlm-http-client @@ -133,7 +133,7 @@ docker run -u root --name mineru_docker --privileged=true \ vlm-<engine_name>-engine 🟢 - 🟡 + 🟢 vlm-http-client @@ -154,10 +154,9 @@ docker run -u root --name mineru_docker --privileged=true \ 注: -🟢: 支持,运行较稳定,精度与Nvidia GPU相对一致 -🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常,或精度略有差异 -🟧: 支持但极度不稳定,在大多数场景下可能出现异常,或精度存在较大差异 -🔴: 不支持,无法运行 +🟢: 支持,运行较稳定,精度与Nvidia GPU基本一致 +🟡: 支持但较不稳定,在某些场景下可能出现异常,或精度存在一定差异 +🔴: 不支持,无法运行,或精度存在较大差异 >[!NOTE] >由于npu卡的特殊性,单次服务启动后,可能会在运行过程中切换推理后端(backend)类型(pipeline/vlm)时出现异常,请尽量根据实际需求选择合适的推理后端进行使用。 diff --git a/docs/zh/usage/acceleration_cards/METAX.md b/docs/zh/usage/acceleration_cards/METAX.md index 9a497bb7..9a129db7 100644 --- a/docs/zh/usage/acceleration_cards/METAX.md +++ b/docs/zh/usage/acceleration_cards/METAX.md @@ -93,7 +93,7 @@ docker run --ipc host \ vlm-<engine_name>-engine 🟢 - 🟡 + 🟢 vlm-http-client @@ -114,7 +114,7 @@ docker run --ipc host \ vlm-<engine_name>-engine 🟢 - 🟡 + 🟢 vlm-http-client @@ -135,7 +135,7 @@ docker run --ipc host \ vlm-<engine_name>-engine 🟢 - 🟡 + 🟢 vlm-http-client @@ -156,10 +156,9 @@ docker run --ipc host \ 注: -🟢: 支持,运行较稳定,精度与Nvidia GPU相对一致 -🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常,或精度略有差异 -🟧: 支持但极度不稳定,在大多数场景下可能出现异常,或精度存在较大差异 -🔴: 不支持,无法运行 +🟢: 支持,运行较稳定,精度与Nvidia GPU基本一致 +🟡: 支持但较不稳定,在某些场景下可能出现异常,或精度存在一定差异 +🔴: 不支持,无法运行,或精度存在较大差异 >[!TIP] >MACA加速卡指定可用加速卡的方式与NVIDIA GPU类似,请参考[使用指定GPU设备](https://opendatalab.github.io/MinerU/zh/usage/advanced_cli_parameters/#cuda_visible_devices)章节说明。 \ No newline at end of file diff --git a/docs/zh/usage/acceleration_cards/THead.md b/docs/zh/usage/acceleration_cards/THead.md index fcf8b095..2aa8b7ae 100644 --- a/docs/zh/usage/acceleration_cards/THead.md +++ b/docs/zh/usage/acceleration_cards/THead.md @@ -85,7 +85,7 @@ docker run --privileged=true \ vlm-<engine_name>-engine 🟢 - 🟡 + 🟢 vlm-http-client @@ -106,7 +106,7 @@ docker run --privileged=true \ vlm-<engine_name>-engine 🟢 - 🟡 + 🟢 vlm-http-client @@ -127,7 +127,7 @@ docker run --privileged=true \ vlm-<engine_name>-engine 🟢 - 🟡 + 🟢 vlm-http-client @@ -141,17 +141,16 @@ docker run --privileged=true \ 数据并行 (--data-parallel-size/--dp) - 🟧 + 🟡 🔴 注: -🟢: 支持,运行较稳定,精度与Nvidia GPU相对一致 -🟡: 支持但稍有不稳定,在少数某些场景下可能出现异常,或精度略有差异 -🟧: 支持但极度不稳定,在大多数场景下可能出现异常,或精度存在较大差异 -🔴: 不支持,无法运行 +🟢: 支持,运行较稳定,精度与Nvidia GPU基本一致 +🟡: 支持但较不稳定,在某些场景下可能出现异常,或精度存在一定差异 +🔴: 不支持,无法运行,或精度存在较大差异 >[!TIP] >PPU加速卡指定可用加速卡的方式与NVIDIA GPU类似,请参考[使用指定GPU设备](https://opendatalab.github.io/MinerU/zh/usage/advanced_cli_parameters/#cuda_visible_devices)章节说明。 \ No newline at end of file From 4d476349139124dad9d461263be2e0ab638f1652 Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 26 Nov 2025 00:23:22 +0800 Subject: [PATCH 62/66] fix: add platform information for testing in Ascend.md, METAX.md, and THead.md --- docs/zh/usage/acceleration_cards/Ascend.md | 1 + docs/zh/usage/acceleration_cards/METAX.md | 1 + docs/zh/usage/acceleration_cards/THead.md | 1 + 3 files changed, 3 insertions(+) diff --git a/docs/zh/usage/acceleration_cards/Ascend.md b/docs/zh/usage/acceleration_cards/Ascend.md index bf23d376..21d9f45c 100644 --- a/docs/zh/usage/acceleration_cards/Ascend.md +++ b/docs/zh/usage/acceleration_cards/Ascend.md @@ -1,4 +1,5 @@ ## 1. 测试平台 +以下为本指南测试使用的平台信息,供参考: ``` os: CTyunOS 22.06 cpu: Kunpeng-920 (aarch64) diff --git a/docs/zh/usage/acceleration_cards/METAX.md b/docs/zh/usage/acceleration_cards/METAX.md index 9a129db7..035f44ec 100644 --- a/docs/zh/usage/acceleration_cards/METAX.md +++ b/docs/zh/usage/acceleration_cards/METAX.md @@ -1,4 +1,5 @@ ## 1. 测试平台 +以下为本指南测试使用的平台信息,供参考: ``` os: Ubuntu 22.04 cpu: INTEL x86_64 diff --git a/docs/zh/usage/acceleration_cards/THead.md b/docs/zh/usage/acceleration_cards/THead.md index 2aa8b7ae..5f5f5be1 100644 --- a/docs/zh/usage/acceleration_cards/THead.md +++ b/docs/zh/usage/acceleration_cards/THead.md @@ -1,4 +1,5 @@ ## 1. 测试平台 +以下为本指南测试使用的平台信息,供参考: ``` os: Ubuntu 22.04 cpu: INTEL x86_64 From 27e1fd63e706f0b83cd4fb3e928a5685392a9b05 Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 26 Nov 2025 10:45:23 +0800 Subject: [PATCH 63/66] fix: clarify feedback process for issues encountered on domestic platform adaptation in README_zh-CN.md --- README_zh-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_zh-CN.md b/README_zh-CN.md index 2f0023ed..8ec98579 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -49,7 +49,7 @@ - 增加新后端`vlm-lmdeploy-engine`支持,使用方式与`vlm-vllm-(async)engine`类似,但使用`lmdeploy`作为推理引擎,与`vllm`相比额外支持Windows平台原生推理加速。 - 新增国产算力平台`昇腾/npu`、`平头哥/ppu`、`沐曦/maca`的适配支持,用户可在对应平台上使用`pipeline`与`vlm`模型,并使用`vllm`/`lmdeploy`引擎加速vlm模型推理,具体使用方式请参考[其他加速卡适配](https://opendatalab.github.io/MinerU/zh/usage/)。 - 国产平台适配不易,我们已尽量确保适配的完整性和稳定性,但仍可能存在一些稳定性/兼容问题与精度对齐问题,请大家根据适配文档页面内红绿灯情况自行选择合适的环境与场景进行使用。 - - 如在使用过程中遇到任何文档未提及的问题,为了其他用户查找解决方案,欢迎在discussions的[指定帖子](https://github.com/opendatalab/MinerU/discussions/4053)中进行反馈。 + - 如在使用国产化平台适配方案的过程中遇到任何文档未提及的问题,为便于其他用户查找解决方案,请在discussions的[指定帖子](https://github.com/opendatalab/MinerU/discussions/4053)中进行反馈。 - 2025/11/04 2.6.4 发布 - 为pdf渲染图片增加超时配置,默认为300秒,可通过环境变量`MINERU_PDF_RENDER_TIMEOUT`进行配置,防止部分异常pdf文件导致渲染过程长时间阻塞。 From ab365420b969d40637e944fe19da72cf108ce30a Mon Sep 17 00:00:00 2001 From: Xiaomeng Zhao Date: Wed, 26 Nov 2025 11:05:08 +0800 Subject: [PATCH 64/66] Update mineru/backend/vlm/utils.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- mineru/backend/vlm/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mineru/backend/vlm/utils.py b/mineru/backend/vlm/utils.py index bd9b1773..2de4d334 100644 --- a/mineru/backend/vlm/utils.py +++ b/mineru/backend/vlm/utils.py @@ -16,7 +16,7 @@ def enable_custom_logits_processors() -> bool: major, minor = torch.cuda.get_device_capability() # 正确计算Compute Capability compute_capability = f"{major}.{minor}" - elif torch.npu.is_available(): + elif hasattr(torch, 'npu') and torch.npu.is_available(): compute_capability = "8.0" else: logger.info("CUDA not available, disabling custom_logits_processors") From 096717e4d014dd6c0515871e51ef6b88f9998b0f Mon Sep 17 00:00:00 2001 From: Xiaomeng Zhao Date: Wed, 26 Nov 2025 11:07:30 +0800 Subject: [PATCH 65/66] Update mineru/cli/vlm_server.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- mineru/cli/vlm_server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mineru/cli/vlm_server.py b/mineru/cli/vlm_server.py index a4cf9dca..61bd47f6 100644 --- a/mineru/cli/vlm_server.py +++ b/mineru/cli/vlm_server.py @@ -32,10 +32,11 @@ def openai_server(ctx, inference_engine): inference_engine = 'vllm' logger.info("Using vLLM as the inference engine for VLM server.") except ImportError: - logger.info("vLLM not found, falling back to LMDeploy as the inference engine for VLM server.") + logger.info("vLLM not found, attempting to use LMDeploy as the inference engine for VLM server.") try: import lmdeploy inference_engine = 'lmdeploy' + # Success message moved after successful import logger.info("Using LMDeploy as the inference engine for VLM server.") except ImportError: logger.error("Neither vLLM nor LMDeploy is installed. Please install at least one of them.") From 0ba3992173d82422c85863141e298863bca4abbe Mon Sep 17 00:00:00 2001 From: Xiaomeng Zhao Date: Wed, 26 Nov 2025 11:09:33 +0800 Subject: [PATCH 66/66] Update docs/zh/usage/acceleration_cards/METAX.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docs/zh/usage/acceleration_cards/METAX.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/usage/acceleration_cards/METAX.md b/docs/zh/usage/acceleration_cards/METAX.md index 035f44ec..330e1fef 100644 --- a/docs/zh/usage/acceleration_cards/METAX.md +++ b/docs/zh/usage/acceleration_cards/METAX.md @@ -66,7 +66,7 @@ docker run --ipc host \ ## 4. 注意事项 -不同环境下,MinerU对ppu加速卡的支持情况如下表所示: +不同环境下,MinerU对maca加速卡的支持情况如下表所示: