mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-15 21:12:30 +08:00
Add missing CUDA development headers required for successful Sage Attention builds, specifically addressing cusparse.h compilation errors. Missing Development Libraries Added: - libcusparse-dev-12-9: Fixes "fatal error: cusparse.h: No such file or directory" - libcublas-dev-12-9: CUBLAS linear algebra library headers - libcurand-dev-12-9: CURAND random number generation headers - libcusolver-dev-12-9: CUSOLVER dense/sparse solver headers - libcufft-dev-12-9: CUFFT Fast Fourier Transform headers Build Performance Enhancement: - ninja-build: Eliminates "could not find ninja" warnings and speeds up compilation Root Cause: Previous installation only included cuda-nvcc-12-9 and cuda-cudart-dev-12-9, but Sage Attention compilation requires the complete set of CUDA math library development headers for linking against PyTorch's CUDA extensions. Compilation Error Resolved: "/usr/local/lib/python3.12/site-packages/torch/include/ATen/cuda/CUDAContextLight.h:8:10: fatal error: cusparse.h: No such file or directory" GPU Detection and Strategy Selection Already Working: - 5x RTX 3060 GPUs detected correctly - PyTorch CUDA compatibility confirmed - RTX 30/40 optimization strategy selected appropriately - Triton 3.4.0 installation successful This provides the complete CUDA development environment needed for Sage Attention source compilation while maintaining the slim image approach.
104 lines
3.2 KiB
Docker
104 lines
3.2 KiB
Docker
# Use a recent slim base image
|
|
FROM python:3.12.11-slim-trixie
|
|
|
|
# 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
|
|
|
|
# Enable non-free repositories and install system deps + CUDA toolkit
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
git \
|
|
build-essential \
|
|
cmake \
|
|
libgl1 \
|
|
libglx-mesa0 \
|
|
libglib2.0-0 \
|
|
fonts-dejavu-core \
|
|
fontconfig \
|
|
util-linux \
|
|
wget \
|
|
gnupg2 \
|
|
ca-certificates \
|
|
ninja-build \
|
|
&& echo "deb http://deb.debian.org/debian trixie main contrib non-free non-free-firmware" > /etc/apt/sources.list.d/non-free.list \
|
|
&& wget https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb \
|
|
&& dpkg -i cuda-keyring_1.1-1_all.deb \
|
|
&& apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
cuda-nvcc-12-9 \
|
|
cuda-cudart-dev-12-9 \
|
|
libcusparse-dev-12-9 \
|
|
libcublas-dev-12-9 \
|
|
libcurand-dev-12-9 \
|
|
libcusolver-dev-12-9 \
|
|
libcufft-dev-12-9 \
|
|
nvidia-smi \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& rm cuda-keyring_1.1-1_all.deb
|
|
|
|
# Set CUDA paths for entrypoint compilation
|
|
ENV CUDA_HOME=/usr/local/cuda-12.9 \
|
|
PATH=/usr/local/cuda-12.9/bin:${PATH} \
|
|
LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64
|
|
|
|
# Create symlink for compatibility
|
|
RUN ln -sf /usr/local/cuda-12.9 /usr/local/cuda
|
|
|
|
# Create runtime user/group (fix the original issue)
|
|
RUN set -e; \
|
|
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; \
|
|
fi; \
|
|
else \
|
|
groupadd --gid 1000 appuser; \
|
|
fi; \
|
|
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; \
|
|
mkdir -p /home/appuser; \
|
|
chown appuser:appuser /home/appuser
|
|
|
|
# Workdir
|
|
WORKDIR /app/ComfyUI
|
|
|
|
# Copy requirements 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 python -m pip install -r requirements.txt; fi \
|
|
&& python -m pip install imageio-ffmpeg "av>=14.2" nvidia-ml-py
|
|
|
|
# Copy the application
|
|
COPY . .
|
|
|
|
# Entrypoint
|
|
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"]
|
|
CMD ["python", "main.py", "--listen", "0.0.0.0"]
|