fix(entrypoint): resolve Triton installation permission errors blocking Sage Attention

Fix critical permission issue preventing Sage Attention from building by using 
--user flag for all pip installations in the entrypoint script.

Root Cause:
- Entrypoint runs as non-root user (appuser) after privilege drop
- Triton installation with --force-reinstall tried to upgrade system setuptools
- System packages require root permissions to uninstall/upgrade
- This caused "Permission denied" errors blocking Sage Attention build

Changes Made:
- Add --user flag to all pip install commands in install_triton_version()
- Add --user flag to Sage Attention pip installation in build_sage_attention_mixed()
- Use --no-build-isolation for Sage Attention to avoid setuptools conflicts
- Maintain all existing fallback logic and error handling

Result:
- Triton installs to user site-packages (~/.local/lib/python3.12/site-packages)
- Sage Attention builds and installs successfully
- No system package conflicts or permission issues
- ComfyUI can now detect and use Sage Attention with --use-sage-attention flag

This resolves the error:
"ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied"

GPU Detection worked perfectly:
- Detected 5x RTX 3060 GPUs correctly  
- PyTorch CUDA compatibility confirmed
- Strategy: rtx30_40_optimized selected appropriately
This commit is contained in:
clsferguson 2025-09-22 11:58:15 -06:00 committed by GitHub
parent cdac5a8b32
commit 976eca9326
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -118,23 +118,23 @@ install_triton_version() {
case "$SAGE_STRATEGY" in
"mixed_with_rtx20"|"rtx20_only")
log "Installing Triton 3.2.0 for RTX 20 series compatibility"
python -m pip install --force-reinstall "triton==3.2.0" || {
python -m pip install --user --force-reinstall "triton==3.2.0" || {
log "WARNING: Failed to install specific Triton version, using default"
python -m pip install --force-reinstall triton || true
python -m pip install --user --force-reinstall triton || true
}
;;
"rtx50_capable")
log "Installing latest Triton for RTX 50 series"
# Try latest first, fallback to pre-release if needed
python -m pip install --force-reinstall triton || \
python -m pip install --force-reinstall --pre triton || {
python -m pip install --user --force-reinstall triton || \
python -m pip install --user --force-reinstall --pre triton || {
log "WARNING: Failed to install latest Triton, using stable"
python -m pip install --force-reinstall "triton>=3.2.0" || true
python -m pip install --user --force-reinstall "triton>=3.2.0" || true
}
;;
*)
log "Installing latest stable Triton"
python -m pip install --force-reinstall triton || {
python -m pip install --user --force-reinstall triton || {
log "WARNING: Triton installation failed, continuing without"
return 1
}
@ -192,9 +192,9 @@ build_sage_attention_mixed() {
;;
esac
# Build with architecture-specific flags
# Build with architecture-specific flags using --user installation
log "Building Sage Attention with multi-GPU support..."
if MAX_JOBS=$(nproc) python setup.py install; then
if MAX_JOBS=$(nproc) python -m pip install --user --no-build-isolation .; then
# Create strategy-specific built flag
echo "$SAGE_STRATEGY" > "$SAGE_ATTENTION_BUILT_FLAG"
log "Sage Attention built successfully for strategy: $SAGE_STRATEGY"