ubuntu 本地部署MinerU完成文档解析
内容创作,内容创作工具,内容创作策略 图文教程

ubuntu 本地部署MinerU完成文档解析

AI中国 AI中国 4 hours ago 183 阅读
4.8 (1280 Rating)
15,328 People learned

1.系统环境配置

(1)检查CUDA环境和GPU状态
需要CUDA11.8或以上

nvcc --version
如无,用下述代码
sudo apt install nvidia-cuda-toolkit
检查GPU状态和显存
(显示的CUDA版本为最高版本)
nvidia-smi
(2)创建虚拟环境避免依赖冲突
先检查自己安装的版本
python --version
conda create -n mineru python=3.12.4conda activate mineru

2.安装MinerU

(1)安装包管理工具

pip install uv

(2)安装MinerU的完整版本
uv pip install -U "mineru[core]" -i https://mirrors.aliyun.com/pypi/simple
下载完成后
(3)安装pytorch GPU版

查看Ubuntu CUDA版本的方法

nvcc -V


CUDA 12.1 向下兼容 12.0)。以下是适配的安装命令:
pip install torch==2.5.0 torchvision==0.20.0 torchaudio==2.5.0 --index-url https://download.pytorch.org/whl/cu121
pip install torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu126

Installing previous versions of PyTorch

We’d prefer you install the latest version, but old binaries and installation instructions are provided below for your convenience.

Commands for Versions >= 1.0.0

Linux and Windows


# ROCM 6.4 (Linux only)
pip install torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/rocm6.4
# CUDA 12.6
pip install torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu126
# CUDA 12.8
pip install torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu128
# CUDA 12.9
pip install torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu129
# CPU only
pip install torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cpu
3.下载模型文件
mineru-models-download --model_type all

输入modelscope

4.功能测试

pdf输入地址:/home/mac/wendang/pdfs

解析输出地址:/home/mac/wendang/test_output

(1)pipeline模式(速度快)

测试单个pdf文件解析(n卡可GPU加速)通过表格,公式,排版等小模型分开识别

cd /home/mac/wendang/mineru -p ./pdfs/demo1.pdf -o test_output/ --backend pipeline device cuda



(2)vlm模式(精度高,速度慢)


通过视觉模型进行识别



mineru -p ./pdfs/demo1.pdf -o test_output/ --backend vlm-transformers --device cuda
(3)批量处理测试
mineru -p ./pdfs -o test_output/ --backend pipeline batch-size 8

5.启动web界面

conda activate mineru
# 启动web服务界面mineru-gradio --server-name 0.0.0.0 --server-port 7860
MinerU帮助文档

https://aicarrier.feishu.cn/wiki/TzBcwXurRiuQZkk17licytSTnBc


Rating

4.8 (1280 Rating)

Comment (0)

睡觉动画