Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Feature Request: Add PaddleOCR GPU support to Docker image

Abierto
#533 1 comentario 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
docker, python

Línea de trabajo

Comienza revisando el Dockerfile existente y la configuración de publicación de imágenes; después, lee unstructured/partition/utils/ocr_models/paddle_ocr.py y OCR_AGENT_BUG_ISSUE.md. Determina si las etiquetas de imagen GPU o los argumentos de compilación están dentro del alcance, y verifica que la imagen seleccionada se compile con las dependencias de PaddleOCR requeridas y admita la ejecución en GPU.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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:latest image 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_AGENT environment 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-gpu from the appropriate CUDA index
  • unstructured-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

  1. Performance: PaddleOCR with GPU is significantly faster than Tesseract for batch processing
  2. Accuracy: PaddleOCR (especially PP-OCRv4) provides better accuracy on many document types
  3. 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

Lenguaje dominante
Python
Estrellas
953
Forks
192
Merge medio
1 d 1 h
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Unstructured-IO/unstructured-api

Todos los issues de Unstructured-IO/unstructured-api

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.