gpu amd 64
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
# Dockerfile.gpu - CUDA-enabled PaddleOCR REST API
|
# Dockerfile.gpu - CUDA-enabled PaddleOCR REST API
|
||||||
#
|
#
|
||||||
# Supports:
|
# Supports both architectures:
|
||||||
# - x86_64: Uses prebuilt paddlepaddle-gpu wheel from PyPI
|
# - x86_64: Uses paddlepaddle-gpu from PaddlePaddle's CUDA index
|
||||||
# - ARM64: Uses locally compiled wheel from ./wheels/ directory
|
# - ARM64: Uses local wheel from ./wheels/ (built on DGX Spark)
|
||||||
#
|
#
|
||||||
# For ARM64, first build the wheel:
|
# For ARM64 (DGX Spark), first build the wheel:
|
||||||
# docker compose run build-paddle
|
# docker compose --profile build run --rm build-paddle
|
||||||
# Then build this image:
|
# Then build this image:
|
||||||
# docker compose build ocr-gpu
|
# 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
|
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/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& ln -sf /usr/bin/python3.11 /usr/bin/python
|
&& ln -sf /usr/bin/python3.11 /usr/bin/python
|
||||||
|
|
||||||
# Copy local wheels directory (may be empty or contain ARM64 wheel)
|
# Copy local wheels directory (may contain ARM64 wheel from build-paddle)
|
||||||
# The wheels/ directory is created by: docker compose run build-paddle
|
|
||||||
COPY wheels/ /tmp/wheels/
|
COPY wheels/ /tmp/wheels/
|
||||||
|
|
||||||
# Install Python dependencies
|
# Copy requirements
|
||||||
# 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 .
|
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 \
|
RUN if ls /tmp/wheels/paddlepaddle*.whl 1>/dev/null 2>&1; then \
|
||||||
echo "=== Installing PaddlePaddle from local wheel (ARM64) ===" && \
|
echo "=== Installing PaddlePaddle from local wheel (ARM64) ===" && \
|
||||||
pip install --no-cache-dir /tmp/wheels/paddlepaddle*.whl; \
|
pip install --no-cache-dir /tmp/wheels/paddlepaddle*.whl; \
|
||||||
else \
|
else \
|
||||||
echo "=== Installing PaddlePaddle from PyPI (x86_64) ===" && \
|
echo "=== Installing PaddlePaddle from CUDA index (x86_64) ===" && \
|
||||||
pip install --no-cache-dir paddlepaddle-gpu==3.0.0; \
|
pip install --no-cache-dir paddlepaddle-gpu==3.2.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/; \
|
||||||
fi
|
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 && \
|
RUN grep -v "paddlepaddle-gpu" requirements-gpu.txt > /tmp/requirements-no-paddle.txt && \
|
||||||
pip install --no-cache-dir -r /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
|
||||||
# Cleanup
|
|
||||||
RUN rm -rf /tmp/wheels /tmp/requirements-no-paddle.txt
|
|
||||||
|
|
||||||
# Copy application code
|
# Copy application code
|
||||||
COPY paddle_ocr_tuning_rest.py .
|
COPY paddle_ocr_tuning_rest.py .
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ docker buildx build -f Dockerfile.cpu \
|
|||||||
docker build -f Dockerfile.gpu -t paddle-ocr-api:gpu .
|
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
|
## Running
|
||||||
|
|
||||||
### CPU (Any machine)
|
### CPU (Any machine)
|
||||||
@@ -448,3 +450,14 @@ Ensure NVIDIA Container Toolkit is installed:
|
|||||||
nvidia-smi # Should work
|
nvidia-smi # Should work
|
||||||
docker run --rm --gpus all nvidia/cuda:12.0-base 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.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Install: pip install -r requirements-gpu.txt
|
# Install: pip install -r requirements-gpu.txt
|
||||||
|
|
||||||
# PaddlePaddle (GPU version with CUDA)
|
# PaddlePaddle (GPU version with CUDA)
|
||||||
paddlepaddle-gpu==3.0.0
|
paddlepaddle-gpu==3.2.0
|
||||||
|
|
||||||
# PaddleOCR
|
# PaddleOCR
|
||||||
paddleocr==3.3.2
|
paddleocr==3.3.2
|
||||||
|
|||||||
Reference in New Issue
Block a user