mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-15 13:02:35 +08:00
Fix critical Docker build failures and upgrade CUDA version for broader GPU support User Creation Fix: - Implement robust GID/UID 1000 conflict resolution with proper error handling - Replace fragile `|| true` pattern with explicit existence checks and fallbacks - Ensure appuser actually exists before chown operations to prevent "invalid user" errors - Add verbose logging during user creation process for debugging CUDA 12.9 Upgrade: - Migrate from CUDA 12.8 to 12.9 base image for full RTX 50 series support - Update PyTorch installation to cu129 wheels for compatibility - Maintain full backward compatibility with RTX 20/30/40 series GPUs Build Reliability Improvements: - Make requirements.txt optional with graceful handling when missing - Skip upgrading system pip/setuptools/wheel to avoid Debian package conflicts - Add PIP_BREAK_SYSTEM_PACKAGES=1 to handle Ubuntu 24.04 PEP 668 restrictions Architecture Support Matrix: - RTX 20 series (Turing): Compute 7.5 - Supported - RTX 30 series (Ampere): Compute 8.6 - Fully supported - RTX 40 series (Ada Lovelace): Compute 8.9 - Fully supported - RTX 50 series (Blackwell): Compute 12.0 - Now supported with CUDA 12.9 Resolves multiple build errors: - "chown: invalid user: 'appuser:appuser'" - "externally-managed-environment" PEP 668 errors - "Cannot uninstall wheel, RECORD file not found" system package conflicts
102 lines
3.1 KiB
Docker
102 lines
3.1 KiB
Docker
# Use NVIDIA CUDA 12.9 devel image for maximum GPU compatibility (RTX 20-50 series)
|
|
FROM nvidia/cuda:12.9.0-devel-ubuntu24.04
|
|
|
|
# Environment
|
|
ENV DEBIAN_FRONTEND=noninteractive \
|
|
PYTHONUNBUFFERED=1 \
|
|
COMFY_AUTO_INSTALL=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_BREAK_SYSTEM_PACKAGES=1 \
|
|
EXT_PARALLEL=4 \
|
|
NVCC_APPEND_FLAGS="--threads 8" \
|
|
MAX_JOBS=32 \
|
|
SAGE_ATTENTION_AVAILABLE=0
|
|
|
|
# System deps including Python 3.12
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
python3.12 \
|
|
python3.12-dev \
|
|
python3.12-venv \
|
|
python3-pip \
|
|
git \
|
|
build-essential \
|
|
cmake \
|
|
libgl1 \
|
|
libglx-mesa0 \
|
|
libglib2.0-0 \
|
|
fonts-dejavu-core \
|
|
fontconfig \
|
|
util-linux \
|
|
wget \
|
|
curl \
|
|
&& ln -sf /usr/bin/python3.12 /usr/bin/python \
|
|
&& ln -sf /usr/bin/python3.12 /usr/bin/python3 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create runtime user/group with proper error handling
|
|
RUN set -e; \
|
|
# Handle existing GID 1000
|
|
if getent group 1000 >/dev/null 2>&1; then \
|
|
EXISTING_GROUP=$(getent group 1000 | cut -d: -f1); \
|
|
echo "GID 1000 exists as group: $EXISTING_GROUP"; \
|
|
if [ "$EXISTING_GROUP" != "appuser" ]; then \
|
|
groupadd appuser; \
|
|
APP_GID=$(getent group appuser | cut -d: -f3); \
|
|
else \
|
|
APP_GID=1000; \
|
|
fi; \
|
|
else \
|
|
groupadd --gid 1000 appuser; \
|
|
APP_GID=1000; \
|
|
fi; \
|
|
# Handle existing UID 1000
|
|
if getent passwd 1000 >/dev/null 2>&1; then \
|
|
EXISTING_USER=$(getent passwd 1000 | cut -d: -f1); \
|
|
echo "UID 1000 exists as user: $EXISTING_USER"; \
|
|
if [ "$EXISTING_USER" != "appuser" ]; then \
|
|
useradd --gid appuser --create-home --shell /bin/bash appuser; \
|
|
fi; \
|
|
else \
|
|
useradd --uid 1000 --gid appuser --create-home --shell /bin/bash appuser; \
|
|
fi; \
|
|
# Ensure home directory exists with correct ownership
|
|
mkdir -p /home/appuser; \
|
|
chown appuser:appuser /home/appuser; \
|
|
echo "Created user: $(id appuser)"; \
|
|
echo "Created group: $(getent group appuser)"
|
|
|
|
# Workdir
|
|
WORKDIR /app/ComfyUI
|
|
|
|
# Copy requirements.txt with optional handling
|
|
COPY requirements.txt* ./
|
|
|
|
# Core Python deps (torch CUDA 12.9, ComfyUI reqs), media/NVML libs
|
|
RUN python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu129 \
|
|
&& python -m pip install triton \
|
|
&& if [ -f requirements.txt ]; then \
|
|
echo "Installing from requirements.txt"; \
|
|
python -m pip install -r requirements.txt; \
|
|
else \
|
|
echo "No requirements.txt found, skipping"; \
|
|
fi \
|
|
&& python -m pip install imageio-ffmpeg "av>=14.2" nvidia-ml-py
|
|
|
|
# Copy the application
|
|
COPY . .
|
|
|
|
# Entrypoint with proper ownership
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh \
|
|
&& chown appuser:appuser /app /home/appuser /entrypoint.sh
|
|
|
|
EXPOSE 8188
|
|
|
|
# Start as root so entrypoint can adjust ownership and drop privileges
|
|
USER root
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
|
# Default command - entrypoint will add --use-sage-attention if available
|
|
CMD ["python", "main.py", "--listen", "0.0.0.0"]
|