This commit is contained in:
2026-01-17 10:46:36 +01:00
parent 27609a0ed0
commit 78fe3e8c81
5 changed files with 358 additions and 45 deletions

View File

@@ -1,6 +1,15 @@
# Dockerfile.gpu - CUDA-enabled PaddleOCR REST API
# Supports: x86_64 with NVIDIA GPU (CUDA 12.x)
# For DGX Spark (ARM64 + CUDA): build natively on the device
#
# Supports:
# - x86_64: Uses prebuilt paddlepaddle-gpu wheel from PyPI
# - ARM64: Uses locally compiled wheel from ./wheels/ directory
#
# For ARM64, first build the wheel:
# docker compose run build-paddle
# Then build this image:
# docker compose build ocr-gpu
#
# See README.md for detailed ARM64 GPU build instructions.
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
@@ -28,9 +37,31 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& ln -sf /usr/bin/python3.11 /usr/bin/python
# Install Python dependencies from requirements file
# Copy local wheels directory (may be empty or contain ARM64 wheel)
# The wheels/ directory is created by: docker compose run build-paddle
COPY wheels/ /tmp/wheels/
# Install Python dependencies
# Strategy:
# 1. If local paddlepaddle wheel exists (ARM64), install it first
# 2. Then install remaining dependencies (excluding paddlepaddle-gpu from requirements)
COPY requirements-gpu.txt .
RUN pip install --no-cache-dir -r requirements-gpu.txt
# Install paddlepaddle: prefer local wheel, fallback to pip
RUN if ls /tmp/wheels/paddlepaddle*.whl 1>/dev/null 2>&1; then \
echo "=== Installing PaddlePaddle from local wheel (ARM64) ===" && \
pip install --no-cache-dir /tmp/wheels/paddlepaddle*.whl; \
else \
echo "=== Installing PaddlePaddle from PyPI (x86_64) ===" && \
pip install --no-cache-dir paddlepaddle-gpu==3.0.0; \
fi
# Install remaining dependencies (skip paddlepaddle-gpu line)
RUN grep -v "paddlepaddle-gpu" requirements-gpu.txt > /tmp/requirements-no-paddle.txt && \
pip install --no-cache-dir -r /tmp/requirements-no-paddle.txt
# Cleanup
RUN rm -rf /tmp/wheels /tmp/requirements-no-paddle.txt
# Copy application code
COPY paddle_ocr_tuning_rest.py .