gpu amd 64
Some checks failed
build_docker / essential (pull_request) Successful in 1s
build_docker / build_cpu (pull_request) Successful in 7s
build_docker / build_gpu (pull_request) Failing after 7m24s

This commit is contained in:
2026-01-17 11:10:13 +01:00
parent 9daa496ab6
commit 02f8500ce5
3 changed files with 29 additions and 21 deletions

View File

@@ -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 .

View File

@@ -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.

View File

@@ -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