Commit Graph

14 Commits

Author SHA1 Message Date
clsferguson
bc2dffa0b0
fix(docker): override PEP 668 externally-managed-environment restriction
Add PIP_BREAK_SYSTEM_PACKAGES=1 environment variable to allow system-wide 
pip installations in Ubuntu 24.04 container environment.

Ubuntu 24.04 includes Python 3.12 with PEP 668 enforcement which blocks 
pip installations outside virtual environments. Since this is a containerized 
environment where system package conflicts are not a concern, we safely 
override this restriction.

Resolves error: "externally-managed-environment" preventing PyTorch and 
dependency installation during Docker build process.
2025-09-22 09:05:19 -06:00
clsferguson
cf52512e20
fix(docker): handle existing GID/UID 1000 in Ubuntu 24.04 base image
Resolve Docker build failure when creating appuser with GID/UID 1000

The Ubuntu 24.04 CUDA base image already contains a user/group with GID 1000, 
causing the Docker build to fail with "groupadd: GID '1000' already exists".

Changes made:
- Add graceful handling for existing GID 1000 using `|| true` pattern
- Add graceful handling for existing UID 1000 to prevent user creation conflicts  
- Ensure /home/appuser directory creation with explicit mkdir -p
- Add explicit ownership assignment (chown 1000:1000) regardless of user creation outcome
- Suppress stderr output from groupadd/useradd commands to reduce build noise

This fix ensures the Docker build succeeds across different CUDA base image versions 
while maintaining the intended UID/GID mapping (1000:1000) required by the entrypoint 
script's permission management system.

The container will now build successfully and the entrypoint script will still be 
able to perform proper user/group remapping at runtime via PUID/PGID environment 
variables as designed.

Fixes build error:
2025-09-22 08:58:02 -06:00
clsferguson
c55980a268
CHANGED METHOD: Replace multi-stage Docker build with single-stage runtime installation approach
This commit significantly simplifies the Docker image architecture by removing the complex multi-stage build process that was causing build failures and compatibility issues across different GPU generations.

Key changes:
- Replace multi-stage builder pattern with runtime-based Sage Attention installation via enhanced entrypoint.sh
- Downgrade from CUDA 12.9 to CUDA 12.8 for broader GPU compatibility (RTX 30+ series)
- Remove pre-built wheel installation in favor of dynamic source compilation during container startup
- Add comprehensive multi-GPU detection and mixed-generation support in entrypoint script
- Integrate intelligent build caching with rebuild detection when GPU configuration changes
- Remove --use-sage-attention from default CMD to allow flexible runtime configuration

Architecture improvements:
- Single FROM nvidia/cuda:12.8.0-devel-ubuntu24.04 (was multi-stage with runtime + devel)
- Simplified package installation without build/runtime separation
- Enhanced Python 3.12 setup with proper symlinks
- Removed complex git SHA resolution and cache-busting mechanisms

Performance optimizations:
- Dynamic CUDA architecture targeting (TORCH_CUDA_ARCH_LIST) based on detected GPUs
- Intelligent Triton version selection (3.2 for RTX 20, latest for RTX 30+)
- Parallel compilation settings moved to environment variables
- Reduced Docker layer count for faster builds and smaller image size

The previous multi-stage approach was abandoned due to:
- Frequent build failures across different CUDA environments
- Complex dependency management between builder and runtime stages
- Inability to handle mixed GPU generations at build time
- Excessive build times and debugging complexity

This runtime-based approach provides better flexibility, reliability, and user experience while maintaining optimal performance through intelligent GPU detection and version selection.
2025-09-22 08:47:37 -06:00
clsferguson
1886bd4b96
build(docker): add CUDA 12.9 multi-stage; bake SageAttention 2.2
Switch from python:3.12-slim-trixie to a multi-stage NVIDIA CUDA 12.9 Ubuntu 22.04 build: use devel for compile (nvcc) and runtime for final image. Compile SageAttention 2.2+ from upstream source during image build by resolving the latest commit and installing without build isolation for a deterministic wheel. Install Triton (>=3.0.0) alongside Torch cu129 and start ComfyUI with --use-sage-attention by default. Add SAGE_FORCE_REFRESH build-arg to re-resolve the ref and bust cache when needed. This improves reproducibility, reduces startup latency, and keeps nvcc out of production for a smaller final image.
2025-09-22 06:30:25 -06:00
clsferguson
7318b3f5d1
fix(build): remove unsupported --break-system-packages from pip wheel in builder 2025-09-21 23:12:06 -06:00
clsferguson
97b4d164ed
build(docker): compile SageAttention 2.2 on slim trixie using Debian CUDA toolkit; install wheel into runtime and enable flag
Switch to a two-stage Dockerfile that builds SageAttention 2.2 from source on python:3.12-slim-trixie by explicitly enabling contrib/non-free/non-free-firmware in APT and installing Debian’s nvidia-cuda-toolkit (nvcc) for compilation, then installs the produced cp312 wheel into the slim runtime so --use-sage-attention works at startup. The builder installs Torch cu129 to match the runtime for ABI compatibility and uses pip’s --break-system-packages to avoid a venv while respecting PEP 668 in a controlled way, keeping layers lean and avoiding the prior sources.list and space issues seen on GitHub runners. The final image remains minimal while bundling an up-to-date SageAttention build aligned with the Torch/CUDA stack in use.
2025-09-21 22:54:12 -06:00
clsferguson
bc0e12819d
build(docker): compile SageAttention 2.2 on slim trixie with Debian CUDA toolkit; install wheel into runtime
Switch to a two-stage build that uses python:3.12-slim-trixie as both builder and runtime, enabling contrib/non-free/non-free-firmware in APT to install Debian’s nvidia-cuda-toolkit (nvcc) for compiling SageAttention 2.2 from source. Install Torch cu129 in the builder and build a cp312 wheel, then copy and install that wheel into the slim runtime so --use-sage-attention works at startup. This removes the heavy CUDA devel base, avoids a venv by permitting pip system installs during build, and keeps the final image minimal while ensuring ABI alignment with Torch cu129.
2025-09-21 22:42:46 -06:00
clsferguson
7b448364d1
fix(build): use CUDA devel builder + venv to build and bundle SageAttention 2.2 wheel; make launch flag effective
Switch the builder stage to nvidia/cuda:12.9.0-devel-ubuntu24.04 and create a Python 3.12 venv to avoid PEP 668 “externally managed” errors, install Torch 2.8.0+cu129 in that venv, and build a cp312 SageAttention 2.2 wheel from upstream; copy and install the wheel in the slim runtime so --use-sage-attention works at startup.
This resolves prior build failures on Debian Trixie slim where CUDA toolkits were unavailable and fixes runtime ModuleNotFoundError by ensuring the module is present in the exact interpreter ComfyUI uses.
2025-09-21 22:15:28 -06:00
clsferguson
8ec3d38c77
fix(build): compile and bundle SageAttention 2.2 using CUDA devel builder so --use-sage-attention works
Switch the builder stage to an NVIDIA CUDA devel image (12.9.0) to provide nvcc and headers, shallow‑clone SageAttention, and build a cp312 wheel against the same Torch (2.8.0+cu129) as the runtime; copy and install the wheel into the slim runtime to ensure the module is present at launch. This replaces the previous approach that only added the launch flag and failed at runtime with ModuleNotFoundError, and avoids apt failures for CUDA packages on Debian Trixie slim while keeping the final image minimal and ABI‑aligned.
2025-09-21 22:07:14 -06:00
clsferguson
f655b2a960
feat(build,docker): add multi-stage build to compile and bundle SageAttention 2.2; enable via --use-sage-attention
Introduce a two-stage Docker build that compiles SageAttention 2.2/2++ from the upstream repository using Debian’s CUDA toolkit (nvcc) and the same Torch stack (cu129) as the runtime, then installs the produced wheel in the final slim image. This ensures the sageattention module is present at launch and makes the existing --use-sage-attention flag functional. The runtime image remains minimal while the builder stage carries heavy toolchains; matching Torch across stages prevents CUDA/ABI mismatch. Also retains the previous launch command so ComfyUI auto-enables SageAttention on startup.
2025-09-21 21:45:26 -06:00
clsferguson
051c46b6dc
feat(build,docker): bake SageAttention 2.2 from source and enable in ComfyUI with --use-sage-attention
Adds a multi-stage Docker build that compiles SageAttention 2.2/2++ from the upstream repository head into a wheel using nvcc, then installs it into the slim runtime to keep images small. Ensures the builder installs the same Torch CUDA 12.9 stack as the runtime so the compiled extension ABI matches at load time. Shallow clones the SageAttention repo during build to always pull the latest version on each new image build. Updates the container launch to pass --use-sage-attention so ComfyUI enables SageAttention at startup when the package is present. This change keeps the runtime minimal while delivering up-to-date, high-performance attention kernels for modern NVIDIA GPUs in ComfyUI.
2025-09-21 21:03:24 -06:00
clsferguson
db7f8730db
build: install PyAV 14+, add nvidia-ml-py, fix torch index
This adds av>=14.2 to satisfy Comfy’s API-node canary, ensuring video/audio nodes import without error, and uses the standard PyTorch CUDA 12.9 index URL syntax for reliability. It also installs nvidia-ml-py to align with the ecosystem shift away from deprecated pynvml, reducing future NVML warnings while preserving current functionality. The rest of the base remains unchanged, and existing ComfyUI requirements continue to install as before.
2025-09-17 12:09:26 -06:00
clsferguson
d4b1a405f5
Switch to Python 3.12 base and add CMake for native builds
Update the Dockerfile to use python:3.12.11-slim-trixie to align with available cp312 wheels (notably MediaPipe) and avoid 3.13 ABI gaps, add cmake alongside build-essential to support native builds like dlib, keep the CUDA-enabled PyTorch install via the vendor index, and leave user/workdir/entrypoint/port settings unchanged to preserve runtime behavior.
2025-09-17 09:54:02 -06:00
clsferguson
cd50c9265a
Add Dockerfile for ComfyUI application setup 2025-09-06 21:41:07 -06:00