modelsinstallscript / install_comfyui.sh
stabletable25's picture
Update install_comfyui.sh
4c5ce88 verified
cd /workspace/madapps
cat > install_comfyui.sh << 'EOF'
#!/usr/bin/env bash
#!/usr/bin/env bash
# ---------------------------------------------------------------------------
# ComfyUI one‑shot installer for RunPod (rev‑2)
# ---------------------------------------------------------------------------
# • Activates your virtualenv
# • Installs official **system** CMake & tool‑chain first (avoids dlib build bug)
# • Removes any pip‑provided cmake that might shadow /usr/bin/cmake
# • Installs Python deps and downloads model weights (idempotent)
# ---------------------------------------------------------------------------
set -euo pipefail
COMFY_DIR="${COMFY_DIR:-/workspace/madapps/ComfyUI}"
VENV="${VENV:-$COMFY_DIR/.venv}"
info() { echo -e "\033[1;32m[INFO]\033[0m $*"; }
warn() { echo -e "\033[1;33m[WARN]\033[0m $*"; }
# ---------------------------------------------------------------------------
# Sanity checks
# ---------------------------------------------------------------------------
if [[ ! -d "$COMFY_DIR" ]]; then
warn "ComfyUI directory '$COMFY_DIR' does not exist. Set COMFY_DIR or clone ComfyUI first."; exit 1; fi
if [[ ! -d "$VENV" ]]; then
warn "Python venv '$VENV' not found. Create it with 'python -m venv $VENV' first."; exit 1; fi
# ---------------------------------------------------------------------------
# Activate env & upgrade pip
# ---------------------------------------------------------------------------
info "Activating virtualenv…"; source "$VENV/bin/activate"
info "Upgrading pip & wheel…"; pip install --upgrade pip wheel
# ---------------------------------------------------------------------------
# System build deps **first** so dlib finds a real /usr/bin/cmake
# ---------------------------------------------------------------------------
APT_CMD="apt-get"; [[ $(id -u) -ne 0 && $(command -v sudo) ]] && APT_CMD="sudo $APT_CMD"
if [[ -n "$APT_CMD" ]]; then
info "Installing system CMake & tool‑chain…"
$APT_CMD update -y && $APT_CMD install -y cmake build-essential python3-dev git wget
fi
# ---------------------------------------------------------------------------
# Ensure pip’s cmake, if present, doesn’t shadow the system one
# ---------------------------------------------------------------------------
if pip show cmake >/dev/null 2>&1; then
warn "Removing pip‑installed cmake to avoid conflicts…"; pip uninstall -y cmake; fi
# ---------------------------------------------------------------------------
# Python packages that need the compiler tool‑chain
# ---------------------------------------------------------------------------
info "Installing Python deps (dlib, insightface)…"
pip install --no-cache-dir dlib insightface
info "Pinning transformers==4.52…"
if pip show transformers >/dev/null 2>&1; then pip uninstall -y transformers; fi
pip install --no-cache-dir transformers==4.52
# ---------------------------------------------------------------------------
# Helper for idempotent downloads
# ---------------------------------------------------------------------------
download() {
local url="$1" dst="$2";
if [[ -f "$dst" ]]; then info "✓ $(basename "$dst") already exists"; else
info "↓ $(basename "$dst")"; wget -q --show-progress -O "$dst" "$url"; fi }
# Create dirs
mkdir -p "$COMFY_DIR/models/"{checkpoints,unet,clip,vae,loras,controlnet}
# ---------------------------------------------------------------------------
# Model weights
# ---------------------------------------------------------------------------
info "Downloading model weights (skip if already present)…"
# Checkpoint
download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/lustifySDXLNSFW_oltFIXEDTEXTURES.safetensors?download=true" \
"$COMFY_DIR/models/checkpoints/lustifySDXLNSFW_oltFIXEDTEXTURES.safetensors"
# UNet
download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/flux1-dev-fp8.safetensors?download=true" \
"$COMFY_DIR/models/unet/flux1-dev-fp8.safetensors"
download "https://huggingface.co/6chan/flux1-kontext-dev-fp8/resolve/main/flux1-kontext-dev-fp8-e4m3fn.safetensors?download=true" \
"$COMFY_DIR/models/unet/flux1-kontext-dev-fp8-e4m3fn.safetensors"
download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/realDream_flux1V1.safetensors?download=true" \
"$COMFY_DIR/models/unet/realDream_flux1V1.safetensors"
# CLIP
download "https://huggingface.co/GraydientPlatformAPI/flux-clip/resolve/main/clip_l.safetensors?download=true" \
"$COMFY_DIR/models/clip/clip_l.safetensors"
download "https://huggingface.co/GraydientPlatformAPI/flux-clip/resolve/main/t5xxl_fp8_e4m3fn.safetensors?download=true" \
"$COMFY_DIR/models/clip/t5xxl_fp8_e4m3fn.safetensors"
# VAE
download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/ae.safetensors?download=true" \
"$COMFY_DIR/models/vae/ae.safetensors"
# Lora
download "https://huggingface.co/XLabs-AI/flux-RealismLora/resolve/main/lora.safetensors?download=true" \
"$COMFY_DIR/models/loras/flux-RealismLora.safetensors"
download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/MysticXXX-v7.safetensors?download=true" \
"$COMFY_DIR/models/loras/MysticXXX-v7.safetensors"
# ControlNet
download "https://huggingface.co/jasperai/Flux.1-dev-Controlnet-Depth/resolve/main/diffusion_pytorch_model.safetensors?download=true" \
"$COMFY_DIR/models/controlnet/jasparaidepth.safetensors"
download "https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0/resolve/main/diffusion_pytorch_model.safetensors?download=true" \
"$COMFY_DIR/models/controlnet/controlnetunionpro2.safetensors"
# ---------------------------------------------------------------------------
info "✔ Setup finished. Launch ComfyUI with:\n cd $COMFY_DIR && bash run.sh"
EOF
chmod +x install_comfyui.sh