le-app/bgbye/Dockerfile.gpu

63 lines
1.7 KiB
Text

FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# System deps (incl. GL + X libs so OpenCV works headless)
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-venv python3-pip wget ca-certificates \
libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Upgrade pip first
RUN python3 -m pip install --upgrade pip
# Core Python deps
RUN python3 -m pip install --no-cache-dir \
onnxruntime-gpu==1.22.0 \
rembg==2.0.67 \
fastapi==0.116.1 \
uvicorn[standard]==0.35.0 \
pillow==11.3.0 \
numpy==2.2.6 \
pydantic==2.11.7 \
opencv-python-headless==4.12.0.88
# PyTorch CUDA 12.4
RUN python3 -m pip install --no-cache-dir \
--index-url https://download.pytorch.org/whl/cu124 \
torch==2.4.1 \
torchvision==0.19.1
# ML + HuggingFace stack (pinned to avoid BRIA RMBG compatibility bug)
RUN python3 -m pip install --no-cache-dir \
transparent-background \
carvekit \
timm \
transformers==4.44.2 \
tokenizers==0.19.1 \
huggingface-hub==0.36.2 \
accelerate
# Your server code
COPY server /app/server
# Remove sudo usage if present (containers already run as root)
RUN if [ -f /app/server/setup.sh ]; then \
sed -i 's/^[[:space:]]*sudo[[:space:]]\+//g' /app/server/setup.sh; \
fi
# Make sure scripts are executable
RUN chmod +x /app/server/setup.sh /app/server/run.sh || true
EXPOSE 7001
# Healthcheck
HEALTHCHECK --interval=30s --timeout=5s --retries=5 \
CMD wget -qO- http://localhost:7001/health || exit 1
# Run API
CMD ["bash", "/app/server/run.sh"]