From 02f8500ce5cbe3b89861a1489d0d2560def457d1 Mon Sep 17 00:00:00 2001 From: sergio Date: Sat, 17 Jan 2026 11:10:13 +0100 Subject: [PATCH] gpu amd 64 --- src/paddle_ocr/Dockerfile.gpu | 35 +++++++++++++---------------- src/paddle_ocr/README.md | 13 +++++++++++ src/paddle_ocr/requirements-gpu.txt | 2 +- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/paddle_ocr/Dockerfile.gpu b/src/paddle_ocr/Dockerfile.gpu index df0e4df..124295a 100644 --- a/src/paddle_ocr/Dockerfile.gpu +++ b/src/paddle_ocr/Dockerfile.gpu @@ -1,15 +1,16 @@ # Dockerfile.gpu - CUDA-enabled PaddleOCR REST API # -# Supports: -# - x86_64: Uses prebuilt paddlepaddle-gpu wheel from PyPI -# - ARM64: Uses locally compiled wheel from ./wheels/ directory +# Supports both architectures: +# - x86_64: Uses paddlepaddle-gpu from PaddlePaddle's CUDA index +# - ARM64: Uses local wheel from ./wheels/ (built on DGX Spark) # -# For ARM64, first build the wheel: -# docker compose run build-paddle +# For ARM64 (DGX Spark), first build the wheel: +# docker compose --profile build run --rm build-paddle # Then build this image: # docker compose build ocr-gpu # -# See README.md for detailed ARM64 GPU build instructions. +# For x86_64, just build directly (no wheel needed): +# docker compose build ocr-gpu FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04 @@ -37,31 +38,25 @@ 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 -# Copy local wheels directory (may be empty or contain ARM64 wheel) -# The wheels/ directory is created by: docker compose run build-paddle +# Copy local wheels directory (may contain ARM64 wheel from 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 COPY requirements-gpu.txt . -# Install paddlepaddle: prefer local wheel, fallback to pip +# Install paddlepaddle: prefer local wheel (ARM64), fallback to CUDA index (x86_64) 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; \ + echo "=== Installing PaddlePaddle from CUDA index (x86_64) ===" && \ + pip install --no-cache-dir paddlepaddle-gpu==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/; \ fi -# Install remaining dependencies (skip paddlepaddle-gpu line) +# Install remaining dependencies (skip paddlepaddle-gpu line from requirements) 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 + pip install --no-cache-dir -r /tmp/requirements-no-paddle.txt && \ + rm -rf /tmp/wheels /tmp/requirements-no-paddle.txt # Copy application code COPY paddle_ocr_tuning_rest.py . diff --git a/src/paddle_ocr/README.md b/src/paddle_ocr/README.md index 113298d..63b296e 100644 --- a/src/paddle_ocr/README.md +++ b/src/paddle_ocr/README.md @@ -129,6 +129,8 @@ docker buildx build -f Dockerfile.cpu \ docker build -f Dockerfile.gpu -t paddle-ocr-api:gpu . ``` +> **Note:** PaddlePaddle GPU 3.x packages are **not on PyPI**. The Dockerfile installs from PaddlePaddle's official CUDA index (`paddlepaddle.org.cn/packages/stable/cu126/`). This is handled automatically during build. + ## Running ### CPU (Any machine) @@ -448,3 +450,14 @@ Ensure NVIDIA Container Toolkit is installed: nvidia-smi # Should work docker run --rm --gpus all nvidia/cuda:12.0-base nvidia-smi # Should work ``` + +### PaddlePaddle GPU installation fails +PaddlePaddle 3.x GPU packages are **not available on PyPI**. They must be installed from PaddlePaddle's official index: +```bash +# For CUDA 12.x +pip install paddlepaddle-gpu==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/ + +# For CUDA 11.8 +pip install paddlepaddle-gpu==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/ +``` +The Dockerfile.gpu handles this automatically. diff --git a/src/paddle_ocr/requirements-gpu.txt b/src/paddle_ocr/requirements-gpu.txt index 56b4832..53e938d 100644 --- a/src/paddle_ocr/requirements-gpu.txt +++ b/src/paddle_ocr/requirements-gpu.txt @@ -2,7 +2,7 @@ # Install: pip install -r requirements-gpu.txt # PaddlePaddle (GPU version with CUDA) -paddlepaddle-gpu==3.0.0 +paddlepaddle-gpu==3.2.0 # PaddleOCR paddleocr==3.3.2