MinerU 笔记

MinerU 用于处理pdf 属于是工作流 最后解析成markdown+json

__version__ = "2.1.10"

##构建虚拟环境,执行环境路径(空间较大),避免依赖过大
conda create -p /root/autodl-tmp/data/mineru python=3.10
conda activate /root/autodl-tmp/data/mineru

## 用git下载代码
git clone https://github.com/opendatalab/MinerU.git
cd MinerU
## 项目用uv工具管理,先下个uv
pip install uv
#阿里云的源好像还没有,换清华的
pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple
## 安装依赖
uv pip install -e .[core] -i https://mirrors.aliyun.com/pypi/simple
#阿里云的源好像403,换清华的
uv pip install -e .[core] --index-url https://pypi.tuna.tsinghua.edu.cn/simple

#依赖超级多,貌似147个(2.1.10)   150个(3.0版本),耐心等待。



## 下载模型(也可以不执行,执行了会下载较多的模型,占用空间)
mineru-models-download

## 执行命令
mineru -p /root/autodl-tmp/data/mineru/input/刘邦的简历.pdf -o /root/autodl-tmp/data/mineru/output -d  cuda 


mineru -p /root/autodl-tmp/input/DeepSeek专题之企业级智能客服.pdf -o /root/autodl-tmp/output 
![image.png](https://upload-images.jianshu.io/upload_images/5047437-9d9a5a66db6c54a6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
报错的话

conda install -c nvidia nccl
检查并修复 PyTorch 环境

确保 PyTorch 版本与 CUDA 匹配

pip uninstall torch torchvision torchaudio
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 # 替换为您的 CUDA 版本

![image.png](https://upload-images.jianshu.io/upload_images/5047437-49ba264f8a43cc4d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


pip install pymupdf




#新版-d移除了  会自动检测设备  --source 也移除了   使用环境变量来设置
export MINERU_MODEL_SOURCE=modelscope

image.png

设置模型下载位置

# 创建模型目录
mkdir -p /root/autodl-tmp/data/mineru/models

# 写入环境变量
echo 'export MODELSCOPE_CACHE=/root/autodl-tmp/data/mineru/models' >> ~/.bashrc
echo 'export MINERU_MODEL_SOURCE=modelscope' >> ~/.bashrc
source ~/.bashrc

2.1.10版本的

cd /root/autodl-tmp/MinerU/projects/multi_gpu_v2


image.png

#完成以上自定义配置后,回到服务器终端,依次执行如下三条命令安装LitServe服务运行所需要的依赖环境:
pip install -U litserve python-multipart filetype
pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118

# 启动脚本
python server.py


3.0版本移除了litserver 内置了自己的多gpu方案


# 单卡直接用
mineru-api --host 0.0.0.0 --port 8000

# 多卡
mineru-router --host 0.0.0.0 --port 8002 --local-gpus auto

image.png

3.0的同步方法

/file_parse

~~

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容