Feature Request: Add PaddleOCR GPU support to Docker image
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- docker, python
调研方向
首先查看现有的 Dockerfile 和镜像发布配置,然后阅读 unstructured/partition/utils/ocr_models/paddle_ocr.py 和 OCR_AGENT_BUG_ISSUE.md。确定 GPU 镜像标签或构建参数是否在范围内,并验证所选镜像能否使用所需的 PaddleOCR 依赖项进行构建且支持 GPU 执行。
由索引模型根据 Issue 内容生成。
描述
Feature Request: Add PaddleOCR GPU support to unstructured-api Docker image
Summary
The official unstructured-api Docker image includes Tesseract but not PaddleOCR. Users who want to use PaddleOCR with GPU acceleration must build a custom image. It would be valuable to have an official GPU-enabled image with PaddleOCR pre-installed.
Current Behavior
- The
unstructured-api:latestimage only includes Tesseract OCR - PaddleOCR must be manually installed via
pip install paddlepaddle unstructured-paddleocr - There is no GPU-enabled variant of the image
- The
OCR_AGENTenvironment variable is ignored (see related issue: OCR_AGENT_BUG_ISSUE.md)
Proposed Solution
Option 1: Provide GPU-enabled image tags
Publish additional Docker image variants:
unstructured-api:latest-gpu-cu118 # CUDA 11.8
unstructured-api:latest-gpu-cu126 # CUDA 12.6
These images would include:
paddlepaddle-gpufrom the appropriate CUDA indexunstructured-paddleocr- NVIDIA CUDA runtime
Option 2: Add build args to existing Dockerfile
Add build arguments to allow users to build GPU-enabled images:
ARG USE_GPU=false
ARG CUDA_VERSION=cu118
RUN if [ "$USE_GPU" = "true" ]; then \
pip install --no-cache-dir \
paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/stable/${CUDA_VERSION}/ \
unstructured-paddleocr; \
fi
Implementation Details
The unstructured library already supports GPU acceleration for PaddleOCR. In unstructured/partition/utils/ocr_models/paddle_ocr.py:
gpu_available = paddle.device.cuda.device_count() > 0
if gpu_available:
logger.info(f"Loading paddle with GPU on language={language}...")
paddle_ocr = PaddleOCR(
use_angle_cls=True,
use_gpu=gpu_available, # Auto-detects GPU
lang=language,
enable_mkldnn=True,
show_log=False,
)
This means the library automatically uses GPU when available - the only requirement is installing paddlepaddle-gpu instead of paddlepaddle.
Workaround
Users can extend the official image:
FROM downloads.unstructured.io/unstructured-io/unstructured-api:latest
USER root
ARG USE_GPU=false
RUN if [ "$USE_GPU" = "true" ]; then \
pip install --no-cache-dir \
paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/stable/cu118/ \
unstructured-paddleocr; \
else \
pip install --no-cache-dir \
paddlepaddle \
unstructured-paddleocr; \
fi
USER notebook-user
ENV OCR_AGENT=unstructured.partition.utils.ocr_models.paddle_ocr.OCRAgentPaddle
Note: This also requires patching general.py to pass ocr_agent to partition() - see OCR_AGENT_BUG_ISSUE.md.
Benefits
- Performance: PaddleOCR with GPU is significantly faster than Tesseract for batch processing
- Accuracy: PaddleOCR (especially PP-OCRv4) provides better accuracy on many document types
- Ease of use: Official GPU images eliminate the need for custom Dockerfiles
Environment
- unstructured-api: latest
- unstructured: 0.18.18+
- PaddlePaddle: 3.2.2
- CUDA: 11.8 / 12.6
Related Issues
- OCR_AGENT environment variable is ignored (see OCR_AGENT_BUG_ISSUE.md)
References
- 主要语言
- Python
- 星标
- 959
- 派生
- 194
- 平均合并
- 22 小时 3 分钟
- 30 天内合并 PR
- 6
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Unstructured-IO/unstructured-api 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 39/100
-
难度 3/5 1-2 天 新手友好度 15/100
查看 Unstructured-IO/unstructured-api 的全部 Issue
相似的 Issue
-
request-theme
难度 1/5 1 小时以内 新手友好度 78/100
LizardByte/ThemerrDB#9883 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
Project-MONAI/MONAI#9258 ·
维护者通常 3 天内回复
-
catalog:deprecation
难度 1/5 1 小时以内 新手友好度 88/100
surendranb/free-inference#31 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
fritzprix/libr-agent#2612 ·
维护者通常 1 天内回复
-
needs-triage presubmit-gate
难度 2/5 1-3 小时 新手友好度 76/100
gke-labs/kube-agents#5001 ·
维护者通常 1 天内回复