mirror of
https://github.com/opendatalab/MinerU.git
synced 2026-09-24 23:10:23 +08:00
docs: update Ubuntu CUDA acceleration guide for version 0.6.2- Add steps for Ubuntu 22.04 LTS installation.
- Detail the process of checking, installing, and configuring NVIDIA drivers. - Include instructions for installing Anaconda and creating a specific environment. - Provide guidance on installing magic-pdf and its dependencies. - Add a note to verify magic-pdf version and report issues if necessary. - Describe the process of downloading models and configuring the application. - Include a sample command to run the application with CUDA acceleration. - Add a note for enabling OCR CUDA acceleration with specific GPU requirements. This update ensures users have the latest information for setting up CUDA accelerationwith magic-pdf on Ubuntu 22.04 LTS, specifically for version 0.6.2, and provides clearer instructions on the installation and configuration process.
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
# Ubuntu 22.04 LTS
|
||||
|
||||
## 1. 更新apt
|
||||
```bash
|
||||
sudo apt-get update
|
||||
```
|
||||
## 2. 检测是否已安装nvidia驱动
|
||||
```bash
|
||||
nvidia-smi
|
||||
```
|
||||
如果看到类似如下的信息,说明已经安装了nvidia驱动,可以跳过步骤3
|
||||
```
|
||||
+---------------------------------------------------------------------------------------+
|
||||
| NVIDIA-SMI 537.34 Driver Version: 537.34 CUDA Version: 12.2 |
|
||||
|-----------------------------------------+----------------------+----------------------+
|
||||
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
|
||||
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
|
||||
| | | MIG M. |
|
||||
|=========================================+======================+======================|
|
||||
| 0 NVIDIA GeForce RTX 3060 Ti WDDM | 00000000:01:00.0 On | N/A |
|
||||
| 0% 51C P8 12W / 200W | 1489MiB / 8192MiB | 5% Default |
|
||||
| | | N/A |
|
||||
+-----------------------------------------+----------------------+----------------------+
|
||||
```
|
||||
## 3. 安装驱动
|
||||
如没有驱动,则通过如下命令
|
||||
```bash
|
||||
sudo apt-get install nvidia-driver-545
|
||||
```
|
||||
安装专有驱动,安装完成后,重启电脑
|
||||
```bash
|
||||
reboot
|
||||
```
|
||||
## 4. 安装anacoda
|
||||
如果已安装conda,可以跳过本步骤
|
||||
```bash
|
||||
wget https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh
|
||||
bash Anaconda3-2024.06-1-Linux-x86_64.sh
|
||||
```
|
||||
最后一步输入yes,关闭终端重新打开
|
||||
## 5. 使用conda 创建环境
|
||||
需指定python版本为3.10
|
||||
```bash
|
||||
conda create -n MinerU python=3.10
|
||||
conda activate MinerU
|
||||
```
|
||||
## 6. 安装应用
|
||||
```bash
|
||||
pip install magic-pdf[full] detectron2 --extra-index-url https://wheels.myhloli.com -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
```
|
||||
> ❗️下载完成后,务必通过以下命令确认magic-pdf的版本是否正确
|
||||
>
|
||||
> ```bash
|
||||
> magic-pdf --version
|
||||
>```
|
||||
> 如果版本号小于0.6.2,请到issue中向我们反馈
|
||||
|
||||
## 7. 下载模型
|
||||
详细参考 [如何下载模型文件](how_to_download_models_zh_cn.md)
|
||||
下载后请将models目录移动到空间较大的ssd磁盘目录
|
||||
|
||||
## 8. 第一次运行前的配置
|
||||
在仓库根目录可以获得 [magic-pdf.template.json](magic-pdf.template.json) 配置模版文件
|
||||
> ❗️务必执行以下命令将配置文件拷贝到【用户目录】下,否则程序将无法运行
|
||||
>
|
||||
> windows的用户目录为 "C:\Users\用户名", linux用户目录为 "/home/用户名", macOS用户目录为 "/Users/用户名"
|
||||
```bash
|
||||
cp magic-pdf.template.json ~/magic-pdf.json
|
||||
```
|
||||
|
||||
在用户目录中找到magic-pdf.json文件并配置"models-dir"为[2. 下载模型权重文件](#2-下载模型权重文件)中下载的模型权重文件所在目录
|
||||
> ❗️务必正确配置模型权重文件所在目录,否则会因为找不到模型文件而导致程序无法运行
|
||||
>
|
||||
> windows系统中应把路径中所有的"\\"替换为"/",否则会因为转义原因导致json文件语法错误。
|
||||
```json
|
||||
{
|
||||
"models-dir": "/tmp/models"
|
||||
}
|
||||
```
|
||||
|
||||
## 9. 第一次运行
|
||||
从仓库中下载样本文件,并测试
|
||||
```bash
|
||||
wget https://github.com/opendatalab/MinerU/raw/master/demo/small_ocr.pdf
|
||||
magic-pdf pdf-command --pdf small_ocr.pdf
|
||||
```
|
||||
## 10. 测试CUDA加速
|
||||
如果您的显卡显存大于等于8G,可以进行以下流程,测试CUDA解析加速效果
|
||||
|
||||
**1.修改【用户目录】中配置文件magic-pdf.json中"device-mode"的值**
|
||||
```json
|
||||
{
|
||||
"device-mode":"cuda"
|
||||
}
|
||||
```
|
||||
**2.运行以下命令测试cuda加速效果**
|
||||
```bash
|
||||
magic-pdf pdf-command --pdf small_ocr.pdf
|
||||
```
|
||||
|
||||
## 11. 为ocr开启cuda加速
|
||||
> ❗️以下操作需显卡显存大于等于16G才可进行,否则会因为显存不足导致程序崩溃或运行速度下降
|
||||
|
||||
**1.下载paddlepaddle-gpu, 安装完成后会自动开启ocr加速**
|
||||
```bash
|
||||
python -m pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
|
||||
```
|
||||
** 2.运行以下命令测试ocr加速效果**
|
||||
```bash
|
||||
magic-pdf pdf-command --pdf small_ocr.pdf
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user