Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: enhance Dockerfile and documentation for vllm and lmdeploy support

myhloli2037a59e3e99
diff --git a/docker/china/mlu.Dockerfile b/docker/china/mlu.Dockerfile
index 98615bc6..7d906b7a 100644
--- a/docker/china/mlu.Dockerfile
+++ b/docker/china/mlu.Dockerfile
@@ -1,6 +1,10 @@
+# 基础镜像配置 vLLM 或 LMDeploy ,请根据实际需要选择其中一个,要求 amd64(x86-64) CPU + Cambricon MLU.
+# Base image containing the LMDEPLOY inference environment, requiring amd64(x86-64) CPU + Cambricon MLU.
+FROM crpi-4crprmm5baj1v8iv.cn-hangzhou.personal.cr.aliyuncs.com/lmdeploy_dlinfer/camb:qwen_vl2.5
+ARG BACKEND=lmdeploy
# Base image containing the vLLM inference environment, requiring amd64(x86-64) CPU + Cambricon MLU.
-FROM
-
+# FROM cambricon-base/pytorch:v25.04.0-torch2.6.0-torchmlu1.26.1-ubuntu22.04-py310
+# ARG BACKEND=vllm
# Install Noto fonts for Chinese characters
RUN apt-get update && \
@@ -13,16 +17,26 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*
# Install mineru latest
-RUN python3 -m pip install -U pip -i https://mirrors.aliyun.com/pypi/simple && \
- python3 -m pip install 'mineru[core]>=2.7.3' \
+RUN /bin/bash -c '\
+ if [ "$BACKEND" = "vllm" ]; then \
+ source /torch/venv3/pytorch_infer/bin/activate; \
+ fi && \
+ python3 -m pip install -U pip -i https://mirrors.aliyun.com/pypi/simple && \
+ python3 -m pip install "mineru[core]>=2.7.3" \
numpy==1.26.4 \
opencv-python==4.11.0.86 \
- accelerate==1.2.0 \
-i https://mirrors.aliyun.com/pypi/simple && \
- python3 -m pip cache purge
+ python3 -m pip install $(if [ "$BACKEND" = "lmdeploy" ]; then echo "accelerate==1.2.0"; else echo "transformers==4.50.3"; fi) && \
+ 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 '\
+ if [ "$BACKEND" = "vllm" ]; then \
+ source /torch/venv3/pytorch_infer/bin/activate; \
+ fi && \
+ mineru-models-download -s modelscope -m all'
+
+WORKDIR /workspace
# 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/docs/zh/usage/acceleration_cards/Cambricon.md b/docs/zh/usage/acceleration_cards/Cambricon.md
index 55c0c20f..18a5fc75 100644
--- a/docs/zh/usage/acceleration_cards/Cambricon.md
+++ b/docs/zh/usage/acceleration_cards/Cambricon.md
@@ -10,13 +10,24 @@ docker: 28.3.0
## 2. 环境准备
-### 2.1 使用 Dockerfile 构建镜像
+>[!NOTE]
+>Ascend加速卡支持使用`vllm`或`lmdeploy`进行VLM模型推理加速。请根据实际需求选择安装和使用其中之一:
+
+### 2.1 使用 Dockerfile 构建镜像 (lmdeploy)
```bash
wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/mlu.Dockerfile
docker build --network=host -t mineru:mlu-lmdeploy-latest -f mlu.Dockerfile .
```
+### 2.2 使用 Dockerfile 构建镜像 (vllm)
+
+```bash
+wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/china/mlu.Dockerfile
+# 将基础镜像从 lmdeploy 切换为 vllm
+sed -i -e '3,4s/^/# /' -e '6,7s/^# //' mlu.Dockerfile
+docker build --network=host -t mineru:mlu-vllm-latest -f mlu.Dockerfile .
+```
## 3. 启动 Docker 容器
@@ -45,18 +56,34 @@ docker run --name mineru_docker \
--security-opt apparmor=unconfined \
-e MINERU_MODEL_SOURCE=local \
-e MINERU_LMDEPLOY_DEVICE=camb \
- --entrypoint /bin/bash \
- -it mineru:mlu-lmdeploy-latest
+ -it mineru:mlu-lmdeploy-latest \
+ /bin/bash
```
+>[!TIP]
+> 请根据实际情况选择使用`vllm`或`lmdeploy`版本的镜像,如需使用`vllm`,请执行以下操作:
+> - 替换上述命令中的`mineru:mlu-lmdeploy-latest`为`mineru:mlu-vllm-latest`
+> - 进入容器后,切换venv环境:
+> ```bash
+> source /torch/venv3/pytorch_infer/bin/activate
+> ```
+
执行该命令后,您将进入到Docker容器的交互式终端,您可以直接在容器内运行MinerU相关命令来使用MinerU的功能。
您也可以直接通过替换`/bin/bash`为服务启动命令来启动MinerU服务,详细说明请参考[通过命令启动服务](https://opendatalab.github.io/MinerU/zh/usage/quick_usage/#apiwebuihttp-clientserver)。
## 4. 注意事项
+>[!NOTE]
+> **兼容性说明**:由于寒武纪(Cambricon)目前对 vLLM v1 引擎的支持尚待完善,MinerU 现阶段采用 v0 引擎作为适配方案。
+> 受此限制,vLLM 的异步引擎(Async Engine)功能存在兼容性问题,可能导致部分使用场景无法正常运行。
+> 我们将持续跟进寒武纪对 vLLM v1 引擎的支持进展,并及时在 MinerU 中进行相应的适配与优化。
+
不同环境下,MinerU对Cambricon加速卡的支持情况如下表所示:
+>[!TIP]
+> 下表中`lmdeploy`黄灯问题为不能批量输出文件夹,单文件输入正常,`vllm`黄灯问题为在精度未对齐,在部分场景下可能出现预期外结果。
+
<table border="1">
<thead>
<tr>
@@ -64,6 +91,7 @@ docker run --name mineru_docker \
<th colspan="2">容器环境</th>
</tr>
<tr>
+ <th>vllm</th>
<th>lmdeploy</th>
</tr>
</thead>
@@ -72,47 +100,58 @@ docker run --name mineru_docker \
<td rowspan="3">命令行工具(mineru)</td>
<td>pipeline</td>
<td>🟢</td>
+ <td>🟢</td>
</tr>
<tr>
<td>&lt;vlm/hybrid&gt;-auto-engine</td>
- <td>🔴</td>
+ <td>🟡</td>
+ <td>🟡</td>
</tr>
<tr>
<td>&lt;vlm/hybrid&gt;-http-client</td>
+ <td>🟡</td>
<td>🟢</td>
</tr>
<tr>
<td rowspan="3">fastapi服务(mineru-api)</td>
<td>pipeline</td>
<td>🟢</td>
+ <td>🟢</td>
</tr>
<tr>
<td>&lt;vlm/hybrid&gt;-auto-engine</td>
+ <td>🔴</td>
<td>🟢</td>
</tr>
<tr>
<td>&lt;vlm/hybrid&gt;-http-client</td>
+ <td>🟡</td>
<td>🟢</td>
</tr>
<tr>
<td rowspan="3">gradio界面(mineru-gradio)</td>
<td>pipeline</td>
<td>🟢</td>
+ <td>🟢</td>
</tr>
<tr>
<td>&lt;vlm/hybrid&gt;-auto-engine</td>
+ <td>🔴</td>
<td>🟢</td>
</tr>
<tr>
<td>&lt;vlm/hybrid&gt;-http-client</td>
+ <td>🟡</td>
<td>🟢</td>
</tr>
<tr>
<td colspan="2">openai-server服务(mineru-openai-server)</td>
+ <td>🟡</td>
<td>🟢</td>
</tr>
<tr>
- <td colspan="2">数据并行 (--data-parallel-size)</td>
+ <td colspan="2">数据并行 (--data-parallel-size/--dp)</td>
+ <td>🔴</td>
<td>🔴</td>
</tr>
</tbody>