Update wanForProduction.sh
Browse files- wanForProduction.sh +193 -427
wanForProduction.sh
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
-
#
|
| 3 |
-
#
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
set -euo pipefail
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
# Cores para output
|
| 9 |
-
# -----------------------------
|
| 10 |
RED='\033[0;31m'
|
| 11 |
GREEN='\033[0;32m'
|
| 12 |
YELLOW='\033[1;33m'
|
|
@@ -18,69 +19,66 @@ log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
| 18 |
log_warn() { echo -e "${YELLOW}[!]${NC} $1"; }
|
| 19 |
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
| 20 |
|
| 21 |
-
command_exists() { command -v "$1" >/dev/null 2>&1; }
|
| 22 |
-
|
| 23 |
-
# -----------------------------
|
| 24 |
# Configuração
|
| 25 |
-
|
| 26 |
-
COMFY_DIR="${COMFY_DIR:-/root/comfy/ComfyUI}"
|
| 27 |
MODELS_DIR="$COMFY_DIR/models"
|
| 28 |
-
COMFY_HOST="
|
| 29 |
-
COMFY_PORT="
|
| 30 |
-
CIVITAI_TOKEN="
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
export MAX_JOBS=${MAX_JOBS:-32}
|
| 35 |
-
export NVCC_APPEND_FLAGS="${NVCC_APPEND_FLAGS:---threads 8}"
|
| 36 |
-
export UV_SYSTEM_PYTHON=1
|
| 37 |
-
export PYTORCH_CUDA_ALLOC_CONF="expandable_segments:True"
|
| 38 |
export HF_HUB_ENABLE_HF_TRANSFER=1
|
| 39 |
-
export HF_TRANSFER_CONCURRENCY=${HF_TRANSFER_CONCURRENCY:-16}
|
| 40 |
-
export EXT_PARALLEL=${EXT_PARALLEL:-4}
|
| 41 |
-
|
| 42 |
-
# -----------------------------
|
| 43 |
-
# Listas de downloads (modelos do CODE2)
|
| 44 |
-
# -----------------------------
|
| 45 |
-
readonly DOWNLOAD_FILES=(
|
| 46 |
-
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors|loras|Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors"
|
| 47 |
-
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors|loras|Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors"
|
| 48 |
-
"hf://Kijai/WanVideo_comfy_fp8_scaled/I2V/Wan2_2-I2V-A14B-HIGH_fp8_e5m2_scaled_KJ.safetensors|diffusion_models|Wan2_2-I2V-A14B-HIGH_fp8_e5m2_scaled_KJ.safetensors"
|
| 49 |
-
"hf://Kijai/WanVideo_comfy_fp8_scaled/I2V/Wan2_2-I2V-A14B-LOW_fp8_e5m2_scaled_KJ.safetensors|diffusion_models|Wan2_2-I2V-A14B-LOW_fp8_e5m2_scaled_KJ.safetensors"
|
| 50 |
-
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_I2V-A14B-4steps-lora_HIGH_fp16.safetensors|loras|Wan2.2-Lightning_I2V-A14B-4steps-lora_HIGH_fp16.safetensors"
|
| 51 |
-
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_I2V-A14B-4steps-lora_LOW_fp16.safetensors|loras|Wan2.2-Lightning_I2V-A14B-4steps-lora_LOW_fp16.safetensors"
|
| 52 |
-
"hf://Kijai/WanVideo_comfy/Wan2_1_VAE_fp32.safetensors|vae|Wan2_1_VAE_fp32.safetensors"
|
| 53 |
-
"hf://Kijai/WanVideo_comfy/umt5-xxl-enc-bf16.safetensors|text_encoders|umt5-xxl-enc-bf16.safetensors"
|
| 54 |
-
"hf://Kijai/WanVideo_comfy/Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank256_bf16.safetensors|loras|lightx2v_I2V_14B_480p_cfg_step_distill_rank256_bf16.safetensors"
|
| 55 |
-
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/vae/wan_2.1_vae.safetensors|vae|wan_2.1_vae.safetensors"
|
| 56 |
-
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/text_encoders/umt5_xxl_fp16.safetensors|text_encoders|umt5_xxl_fp16.safetensors"
|
| 57 |
-
"hf://Kijai/WanVideo_comfy/open-clip-xlm-roberta-large-vit-huge-14_visual_fp32.safetensors|clip_vision|open-clip-xlm-roberta-large-vit-huge-14_visual_fp32.safetensors"
|
| 58 |
-
"hf://Comfy-Org/Wan_2.1_ComfyUI_repackaged/split_files/clip_vision/clip_vision_h.safetensors|clip_vision|clip_vision_h.safetensors"
|
| 59 |
-
"https://huggingface.co/ABDALLALSWAITI/Upscalers/resolve/main/anime/2x-AnimeSharpV2_MoSR_Soft.pth|upscale_models|2x-AnimeSharpV2_MoSR_Soft.pth"
|
| 60 |
-
)
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
"https://
|
| 69 |
-
"https://
|
| 70 |
-
"https://
|
| 71 |
-
"https://
|
| 72 |
-
"https://
|
| 73 |
-
"https://
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
-
"https://mega.nz/file/
|
| 78 |
-
"https://mega.nz/file/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
)
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
| 84 |
"https://github.com/kijai/ComfyUI-Florence2"
|
| 85 |
"https://github.com/adbrasi/groqrouter"
|
| 86 |
"https://github.com/kijai/ComfyUI-WanVideoWrapper"
|
|
@@ -107,452 +105,220 @@ readonly CUSTOM_NODES=(
|
|
| 107 |
"https://github.com/grmchn/ComfyUI-ProportionChanger"
|
| 108 |
)
|
| 109 |
|
| 110 |
-
#
|
| 111 |
-
# Funções
|
| 112 |
-
#
|
| 113 |
-
apt_update_safe() {
|
| 114 |
-
if command_exists apt-get; then
|
| 115 |
-
export DEBIAN_FRONTEND=noninteractive
|
| 116 |
-
apt-get update -y || log_warn "apt-get update falhou; seguindo mesmo assim."
|
| 117 |
-
else
|
| 118 |
-
log_warn "apt-get não disponível; pulando update."
|
| 119 |
-
fi
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
apt_install_safe() {
|
| 123 |
-
if command_exists apt-get; then
|
| 124 |
-
export DEBIAN_FRONTEND=noninteractive
|
| 125 |
-
apt-get install -y "$@" || log_warn "Falha ao instalar pacote(s): $*"
|
| 126 |
-
else
|
| 127 |
-
log_warn "apt-get não disponível; não foi possível instalar: $*"
|
| 128 |
-
fi
|
| 129 |
-
}
|
| 130 |
-
|
| 131 |
-
stat_bytes() {
|
| 132 |
-
local path="$1"
|
| 133 |
-
stat -c%s "$path" 2>/dev/null || echo 0
|
| 134 |
-
}
|
| 135 |
-
|
| 136 |
-
add_civitai_token() {
|
| 137 |
-
local url="$1"
|
| 138 |
-
if [[ "$url" == *"civitai.com/api/download"* ]] && [[ "$url" != *"token="* ]] && [[ -n "$CIVITAI_TOKEN" ]]; then
|
| 139 |
-
if [[ "$url" == *"?"* ]]; then
|
| 140 |
-
printf '%s&token=%s' "$url" "$CIVITAI_TOKEN"
|
| 141 |
-
else
|
| 142 |
-
printf '%s?token=%s' "$url" "$CIVITAI_TOKEN"
|
| 143 |
-
fi
|
| 144 |
-
else
|
| 145 |
-
printf '%s' "$url"
|
| 146 |
-
fi
|
| 147 |
-
}
|
| 148 |
|
| 149 |
download_hf() {
|
| 150 |
-
local
|
| 151 |
-
local
|
| 152 |
-
local
|
| 153 |
-
local filename="$4"
|
| 154 |
-
|
| 155 |
-
if [[ -z "$filename" ]]; then
|
| 156 |
-
filename="$(basename "$file_path")"
|
| 157 |
-
fi
|
| 158 |
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
log_success "Arquivo já existe: $filename"
|
| 162 |
return 0
|
| 163 |
fi
|
| 164 |
|
| 165 |
-
log_info "Baixando
|
| 166 |
-
local temp_dir
|
| 167 |
-
temp_dir="$(mktemp -d)"
|
| 168 |
-
local success=false
|
| 169 |
-
|
| 170 |
-
if command_exists hf; then
|
| 171 |
-
if HF_HUB_ENABLE_HF_TRANSFER=1 hf download "$repo" "$file_path" --local-dir "$temp_dir" --local-dir-use-symlinks False; then
|
| 172 |
-
success=true
|
| 173 |
-
else
|
| 174 |
-
log_warn "hf download falhou; tentando fallback."
|
| 175 |
-
fi
|
| 176 |
-
fi
|
| 177 |
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
fi
|
| 184 |
fi
|
| 185 |
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
header="Authorization: Bearer ${HF_TOKEN}"
|
| 191 |
-
fi
|
| 192 |
-
if command_exists aria2c; then
|
| 193 |
-
local aria_cmd=(aria2c -c -s 16 -x 16 -k 1M --console-log-level=warn --summary-interval=10)
|
| 194 |
-
if [[ -n "$header" ]]; then
|
| 195 |
-
aria_cmd+=(--header="$header")
|
| 196 |
-
fi
|
| 197 |
-
aria_cmd+=(--dir="$temp_dir" --out="$filename" "$direct_url")
|
| 198 |
-
if "${aria_cmd[@]}"; then
|
| 199 |
-
success=true
|
| 200 |
-
else
|
| 201 |
-
log_warn "aria2c direto falhou; tentando curl/wget."
|
| 202 |
-
fi
|
| 203 |
-
fi
|
| 204 |
-
if [[ "$success" == false ]] && command_exists curl; then
|
| 205 |
-
local curl_cmd=(curl -L -# -o "$temp_dir/$filename")
|
| 206 |
-
if [[ -n "$header" ]]; then
|
| 207 |
-
curl_cmd+=(-H "$header")
|
| 208 |
-
fi
|
| 209 |
-
curl_cmd+=("$direct_url")
|
| 210 |
-
if "${curl_cmd[@]}"; then
|
| 211 |
-
success=true
|
| 212 |
-
fi
|
| 213 |
-
fi
|
| 214 |
-
if [[ "$success" == false ]] && command_exists wget; then
|
| 215 |
-
local wget_cmd=(wget -q --show-progress -c -O "$temp_dir/$filename")
|
| 216 |
-
if [[ -n "$header" ]]; then
|
| 217 |
-
wget_cmd+=(--header="$header")
|
| 218 |
-
fi
|
| 219 |
-
wget_cmd+=("$direct_url")
|
| 220 |
-
if "${wget_cmd[@]}"; then
|
| 221 |
-
success=true
|
| 222 |
-
fi
|
| 223 |
-
fi
|
| 224 |
-
fi
|
| 225 |
|
| 226 |
-
if
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
|
|
|
| 236 |
fi
|
| 237 |
-
|
| 238 |
-
rm -rf "$temp_dir"
|
| 239 |
-
log_error "Falha ao baixar: $filename"
|
| 240 |
-
return 1
|
| 241 |
}
|
| 242 |
|
| 243 |
-
|
| 244 |
local url="$1"
|
| 245 |
local target_dir="$2"
|
| 246 |
-
local filename="$3"
|
| 247 |
-
|
| 248 |
-
url="$(add_civitai_token "$url")"
|
| 249 |
-
mkdir -p "$target_dir"
|
| 250 |
-
|
| 251 |
-
local final_name="$filename"
|
| 252 |
-
if [[ -z "$final_name" ]]; then
|
| 253 |
-
final_name="$(basename "${url%%\?*}")"
|
| 254 |
-
fi
|
| 255 |
|
| 256 |
-
|
| 257 |
-
log_success "Arquivo já existe: $final_name"
|
| 258 |
-
return 0
|
| 259 |
-
fi
|
| 260 |
|
| 261 |
-
log_info "Baixando
|
| 262 |
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
log_warn "aria2c falhou; tentando wget/curl."
|
| 269 |
-
fi
|
| 270 |
-
|
| 271 |
-
if command_exists wget; then
|
| 272 |
-
if wget -q --show-progress -c -O "$target_dir/$final_name" "$url"; then
|
| 273 |
-
return 0
|
| 274 |
-
fi
|
| 275 |
-
log_warn "wget falhou; tentando curl."
|
| 276 |
-
fi
|
| 277 |
-
|
| 278 |
-
if command_exists curl; then
|
| 279 |
-
if curl -L -# -C - -o "$target_dir/$final_name" "$url"; then
|
| 280 |
-
return 0
|
| 281 |
-
fi
|
| 282 |
fi
|
| 283 |
-
|
| 284 |
-
log_error "Falha ao baixar: $url"
|
| 285 |
-
return 1
|
| 286 |
}
|
| 287 |
|
| 288 |
-
|
| 289 |
local url="$1"
|
| 290 |
local target_dir="$2"
|
|
|
|
| 291 |
|
| 292 |
-
|
| 293 |
-
|
|
|
|
|
|
|
| 294 |
|
| 295 |
-
if
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
apt_install_safe megatools
|
| 299 |
fi
|
| 300 |
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
fi
|
| 308 |
-
|
| 309 |
-
log_error "Falha ao baixar de Mega.nz: $url"
|
| 310 |
-
return 1
|
| 311 |
}
|
| 312 |
|
| 313 |
process_downloads() {
|
| 314 |
-
local failed=0
|
| 315 |
for entry in "${DOWNLOAD_FILES[@]}"; do
|
| 316 |
-
IFS='|' read -r
|
| 317 |
-
raw_url="$(echo "$raw_url" | xargs)"
|
| 318 |
-
type="$(echo "$type" | xargs)"
|
| 319 |
-
filename="$(echo "$filename" | xargs)"
|
| 320 |
|
| 321 |
local target_dir="$MODELS_DIR/$type"
|
| 322 |
mkdir -p "$target_dir"
|
| 323 |
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
fi
|
| 332 |
-
for attempt in 1 2 3; do
|
| 333 |
-
if [[ "$raw_url" == mega://* ]]; then
|
| 334 |
-
if download_mega "$raw_url" "$target_dir"; then
|
| 335 |
-
success=true
|
| 336 |
-
fi
|
| 337 |
-
elif [[ "$raw_url" == hf://* ]]; then
|
| 338 |
-
local trimmed="${raw_url#hf://}"
|
| 339 |
-
local repo="$(echo "$trimmed" | cut -d'/' -f1-2)"
|
| 340 |
-
local file_path="$(echo "$trimmed" | cut -d'/' -f3-)"
|
| 341 |
-
if download_hf "$repo" "$file_path" "$target_dir" "$filename"; then
|
| 342 |
-
success=true
|
| 343 |
-
fi
|
| 344 |
-
else
|
| 345 |
-
if download_file "$raw_url" "$target_dir" "$filename"; then
|
| 346 |
-
success=true
|
| 347 |
-
fi
|
| 348 |
-
fi
|
| 349 |
-
|
| 350 |
-
if [[ "$success" == true ]]; then
|
| 351 |
-
break
|
| 352 |
-
fi
|
| 353 |
-
|
| 354 |
-
log_warn "Tentativa $attempt falhou para $label; aguardando antes de tentar novamente."
|
| 355 |
-
sleep $((2 * attempt))
|
| 356 |
-
done
|
| 357 |
-
|
| 358 |
-
if [[ "$success" == false ]]; then
|
| 359 |
-
log_error "Falhou após múltiplas tentativas: $label"
|
| 360 |
-
((failed++))
|
| 361 |
fi
|
| 362 |
done
|
| 363 |
-
|
| 364 |
-
return $failed
|
| 365 |
}
|
| 366 |
|
| 367 |
-
|
| 368 |
local url="$1"
|
| 369 |
local dest="$2"
|
| 370 |
-
local node_name
|
| 371 |
-
node_name="$(basename "$dest")"
|
| 372 |
-
|
| 373 |
-
mkdir -p "$(dirname "$dest")"
|
| 374 |
|
| 375 |
-
if [
|
| 376 |
-
|
| 377 |
-
if ! timeout 120 git -C "$dest" pull --ff-only --rebase=false; then
|
| 378 |
-
log_warn "Timeout/erro ao atualizar $node_name"
|
| 379 |
-
fi
|
| 380 |
else
|
| 381 |
-
|
| 382 |
-
if ! timeout 120 git clone --recursive --depth 1 "$url" "$dest"; then
|
| 383 |
-
log_warn "Falha ao clonar $node_name"
|
| 384 |
-
return
|
| 385 |
-
fi
|
| 386 |
fi
|
| 387 |
|
| 388 |
-
if [
|
| 389 |
-
|
| 390 |
-
log_warn "Falha ao instalar requirements para $node_name"
|
| 391 |
-
fi
|
| 392 |
fi
|
| 393 |
}
|
| 394 |
|
| 395 |
-
|
| 396 |
-
log_info "[5/9] Instalando SageAttention..."
|
| 397 |
-
if python3 - <<'PY' 2>/dev/null | grep -q True; then
|
| 398 |
-
import torch
|
| 399 |
-
print(torch.cuda.is_available())
|
| 400 |
-
PY
|
| 401 |
-
if python3 -m pip install "https://huggingface.co/adbrasi/comfywheel/resolve/main/sageattention-2.2.0-cp311-cp311-linux_x86_64.whl" -q; then
|
| 402 |
-
if python3 - <<'PY' >/dev/null 2>&1; then
|
| 403 |
-
import sageattention
|
| 404 |
-
PY
|
| 405 |
-
log_success "SageAttention instalado"
|
| 406 |
-
else
|
| 407 |
-
log_warn "SageAttention instalado mas não pôde ser importado"
|
| 408 |
-
fi
|
| 409 |
-
else
|
| 410 |
-
log_warn "Falha ao instalar SageAttention"
|
| 411 |
-
fi
|
| 412 |
-
else
|
| 413 |
-
log_warn "CUDA não detectado; pulando SageAttention"
|
| 414 |
-
fi
|
| 415 |
-
}
|
| 416 |
|
| 417 |
-
# -----------------------------
|
| 418 |
-
# Instalação principal
|
| 419 |
-
# -----------------------------
|
| 420 |
log_info "========================================="
|
| 421 |
-
log_info " ComfyUI
|
| 422 |
log_info "========================================="
|
| 423 |
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
apt_update_safe
|
| 427 |
-
command_exists aria2c || apt_install_safe aria2
|
| 428 |
-
command_exists megadl || apt_install_safe megatools
|
| 429 |
-
fi
|
| 430 |
-
for cmd in python3 git wget curl; do
|
| 431 |
-
if ! command_exists "$cmd"; then
|
| 432 |
-
log_error "Dependência faltando: $cmd"
|
| 433 |
-
exit 1
|
| 434 |
-
fi
|
| 435 |
-
done
|
| 436 |
-
log_success "Dependências de sistema OK"
|
| 437 |
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
python3 -m pip install --upgrade "huggingface_hub[cli,hf_transfer]>=0.26.0" comfy-cli -q
|
| 441 |
-
if [[ -n "$HF_TOKEN" ]] && command_exists huggingface-cli; then
|
| 442 |
-
huggingface-cli login --token "$HF_TOKEN" --add-to-git-credential || log_warn "Falha ao autenticar no HuggingFace"
|
| 443 |
-
fi
|
| 444 |
-
if command_exists hf; then
|
| 445 |
-
log_success "Ferramenta 'hf' disponível"
|
| 446 |
-
elif command_exists huggingface-cli; then
|
| 447 |
-
log_warn "Usando 'huggingface-cli' para downloads"
|
| 448 |
-
else
|
| 449 |
-
log_warn "Sem CLI oficial do HuggingFace; tentaremos fallback HTTP"
|
| 450 |
-
fi
|
| 451 |
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
log_success "PyTorch com CUDA 12.8 instalado"
|
| 455 |
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 459 |
else
|
| 460 |
comfy --skip-prompt install --fast-deps --nvidia
|
| 461 |
-
if [[ ! -f "$COMFY_DIR/main.py" ]]; then
|
| 462 |
-
log_error "ComfyUI não foi instalado corretamente"
|
| 463 |
-
exit 1
|
| 464 |
-
fi
|
| 465 |
fi
|
| 466 |
-
log_success "ComfyUI disponível em $COMFY_DIR"
|
| 467 |
|
| 468 |
-
|
| 469 |
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
else
|
| 475 |
-
log_warn "Alguns modelos falharam. Consulte logs acima e tente novamente."
|
| 476 |
-
fi
|
| 477 |
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 487 |
else
|
| 488 |
-
log_warn "
|
| 489 |
fi
|
| 490 |
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
fi
|
| 499 |
-
if (( ${#MEGA_UPSCALE[@]} )); then
|
| 500 |
-
UPSCALE_DIR="$MODELS_DIR/upscale_models"
|
| 501 |
-
mkdir -p "$UPSCALE_DIR"
|
| 502 |
-
for url in "${MEGA_UPSCALE[@]}"; do
|
| 503 |
-
download_mega "$url" "$UPSCALE_DIR" || log_warn "Mega.nz falhou: $url"
|
| 504 |
-
done
|
| 505 |
-
fi
|
| 506 |
-
log_success "Downloads Mega.nz concluídos (quando disponíveis)"
|
| 507 |
|
| 508 |
-
log_info "[9/9] Instalando custom nodes..."
|
| 509 |
CN_DIR="$COMFY_DIR/custom_nodes"
|
| 510 |
mkdir -p "$CN_DIR"
|
|
|
|
| 511 |
total_nodes=${#CUSTOM_NODES[@]}
|
| 512 |
current_node=0
|
|
|
|
| 513 |
for repo in "${CUSTOM_NODES[@]}"; do
|
| 514 |
((current_node++))
|
| 515 |
-
|
| 516 |
-
|
|
|
|
| 517 |
done
|
| 518 |
-
log_success "Custom nodes instalados"
|
| 519 |
|
| 520 |
-
|
| 521 |
-
local files=(
|
| 522 |
-
"$COMFY_DIR/main.py"
|
| 523 |
-
"$MODELS_DIR/vae/wan_2.1_vae.safetensors"
|
| 524 |
-
"$MODELS_DIR/vae/Wan2_1_VAE_fp32.safetensors"
|
| 525 |
-
"$MODELS_DIR/text_encoders/umt5_xxl_fp16.safetensors"
|
| 526 |
-
"$MODELS_DIR/text_encoders/umt5-xxl-enc-bf16.safetensors"
|
| 527 |
-
"$MODELS_DIR/clip_vision/clip_vision_h.safetensors"
|
| 528 |
-
)
|
| 529 |
-
local missing=0
|
| 530 |
-
for file in "${files[@]}"; do
|
| 531 |
-
if [[ -f "$file" ]]; then
|
| 532 |
-
log_success "✓ $(basename "$file")"
|
| 533 |
-
else
|
| 534 |
-
log_warn "✗ $(basename "$file") não encontrado"
|
| 535 |
-
((missing++))
|
| 536 |
-
fi
|
| 537 |
-
done
|
| 538 |
-
return $missing
|
| 539 |
-
}
|
| 540 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
log_info "========================================="
|
| 542 |
-
if check_critical_files; then
|
| 543 |
-
log_success "Instalação concluída com sucesso!"
|
| 544 |
-
else
|
| 545 |
-
log_warn "Alguns arquivos essenciais não foram encontrados. Veja avisos acima."
|
| 546 |
-
fi
|
| 547 |
-
log_info "Preparando para iniciar ComfyUI..."
|
| 548 |
|
|
|
|
|
|
|
|
|
|
| 549 |
SAGE_FLAG=""
|
| 550 |
-
if python3 -
|
| 551 |
-
import sageattention
|
| 552 |
-
PY
|
| 553 |
SAGE_FLAG="--use-sage-attention"
|
| 554 |
fi
|
| 555 |
|
| 556 |
-
cd "$COMFY_DIR"
|
| 557 |
-
log_info "Iniciando ComfyUI em http://$COMFY_HOST:$COMFY_PORT"
|
| 558 |
exec comfy launch -- ${SAGE_FLAG:+$SAGE_FLAG} --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
|
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
+
# setup_comfyui_simple.sh (base do CODE1, ajustado)
|
| 3 |
+
# - troca de modelos/nodes pelos do CODE2
|
| 4 |
+
# - adiciona SageAttention
|
| 5 |
+
# - remove tratamento 5090/Blackwell
|
| 6 |
+
# - melhora download_hf para paths com subpastas e /resolve/
|
| 7 |
|
| 8 |
set -euo pipefail
|
| 9 |
|
| 10 |
+
# Cores
|
|
|
|
|
|
|
| 11 |
RED='\033[0;31m'
|
| 12 |
GREEN='\033[0;32m'
|
| 13 |
YELLOW='\033[1;33m'
|
|
|
|
| 19 |
log_warn() { echo -e "${YELLOW}[!]${NC} $1"; }
|
| 20 |
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
| 21 |
|
|
|
|
|
|
|
|
|
|
| 22 |
# Configuração
|
| 23 |
+
COMFY_DIR="/root/comfy/ComfyUI"
|
|
|
|
| 24 |
MODELS_DIR="$COMFY_DIR/models"
|
| 25 |
+
COMFY_HOST="0.0.0.0"
|
| 26 |
+
COMFY_PORT="8818"
|
| 27 |
+
CIVITAI_TOKEN="4fcb2834969399006a736ee402b061e5"
|
| 28 |
+
|
| 29 |
+
# Performance
|
| 30 |
+
export MAX_JOBS=32
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
export HF_HUB_ENABLE_HF_TRANSFER=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
# ===============================
|
| 34 |
+
# Lista de downloads (do CODE2)
|
| 35 |
+
# ===============================
|
| 36 |
+
# Formato: "URL|TIPO|NOME_OPCIONAL"
|
| 37 |
+
DOWNLOAD_FILES=(
|
| 38 |
+
# Wan 2.2 (Kijai) - use URLs SEM /resolve/ para usar o CLI da HF
|
| 39 |
+
"https://huggingface.co/Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors|loras|Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors"
|
| 40 |
+
"https://huggingface.co/Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors|loras|Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors"
|
| 41 |
+
"https://huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/I2V/Wan2_2-I2V-A14B-HIGH_fp8_e5m2_scaled_KJ.safetensors|diffusion_models|Wan2_2-I2V-A14B-HIGH_fp8_e5m2_scaled_KJ.safetensors"
|
| 42 |
+
"https://huggingface.co/Kijai/WanVideo_comfy_fp8_scaled/I2V/Wan2_2-I2V-A14B-LOW_fp8_e5m2_scaled_KJ.safetensors|diffusion_models|Wan2_2-I2V-A14B-LOW_fp8_e5m2_scaled_KJ.safetensors"
|
| 43 |
+
"https://huggingface.co/Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_I2V-A14B-4steps-lora_HIGH_fp16.safetensors|loras|Wan2.2-Lightning_I2V-A14B-4steps-lora_HIGH_fp16.safetensors"
|
| 44 |
+
"https://huggingface.co/Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_I2V-A14B-4steps-lora_LOW_fp16.safetensors|loras|Wan2.2-Lightning_I2V-A14B-4steps-lora_LOW_fp16.safetensors"
|
| 45 |
+
"https://huggingface.co/Kijai/WanVideo_comfy/Wan2_1_VAE_fp32.safetensors|vae|Wan2_1_VAE_fp32.safetensors"
|
| 46 |
+
"https://huggingface.co/Kijai/WanVideo_comfy/umt5-xxl-enc-bf16.safetensors|text_encoders|umt5-xxl-enc-bf16.safetensors"
|
| 47 |
+
|
| 48 |
+
# Wan 2.1
|
| 49 |
+
"https://huggingface.co/Kijai/WanVideo_comfy/Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank256_bf16.safetensors|loras|lightx2v_I2V_14B_480p_cfg_step_distill_rank256_bf16.safetensors"
|
| 50 |
+
"https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/vae/wan_2.1_vae.safetensors|vae|wan_2.1_vae.safetensors"
|
| 51 |
+
"https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/text_encoders/umt5_xxl_fp16.safetensors|text_encoders|umt5_xxl_fp16.safetensors"
|
| 52 |
+
|
| 53 |
+
# Wan 2.1 clip vision
|
| 54 |
+
"https://huggingface.co/Kijai/WanVideo_comfy/open-clip-xlm-roberta-large-vit-huge-14_visual_fp32.safetensors|clip_vision|open-clip-xlm-roberta-large-vit-huge-14_visual_fp32.safetensors"
|
| 55 |
+
"https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/split_files/clip_vision/clip_vision_h.safetensors|clip_vision|clip_vision_h.safetensors"
|
| 56 |
+
|
| 57 |
+
# Upscaler extra (com /resolve/ para baixar via HTTP direto)
|
| 58 |
+
"https://huggingface.co/ABDALLALSWAITI/Upscalers/resolve/main/anime/2x-AnimeSharpV2_MoSR_Soft.pth|upscale_models|2x-AnimeSharpV2_MoSR_Soft.pth"
|
| 59 |
|
| 60 |
+
# LoRAs via Mega.nz (do CODE2) — prefixo mega:// para usar função existente
|
| 61 |
+
"mega://https://mega.nz/file/QFxREJpZ#0dge8TyRgb52lMFKdsk-Ac-rwcoG49hvBHvaqNsZkuk|loras|"
|
| 62 |
+
"mega://https://mega.nz/file/lIhQETjT#nKlQ01Euw6fUxo8P5bfwlQrxAkWEedXQQOqHv5u4yrM|loras|"
|
| 63 |
+
"mega://https://mega.nz/file/UIAESACY#Qlei1Pj5Nwno3Sz-wsTekvD-YgCkN1A5QbFKoRHXG9E|loras|"
|
| 64 |
+
"mega://https://mega.nz/file/cdAg1Q7D#tQVrer2sB-M7XdYiKAqr7kRRfJw4pXCdliOg2aPJUGE|loras|"
|
| 65 |
+
"mega://https://mega.nz/file/5RQFiAAJ#QCWrHkuJjXlFufR18g5R9YXJGqJ1pQp7xbqNRgSYUjc|loras|"
|
| 66 |
+
"mega://https://mega.nz/file/tABgxLTS#NNlPV8NPc7R52MIjABMFUb41EOFDxFoszBxOrPMN13Q|loras|"
|
| 67 |
+
"mega://https://mega.nz/file/4MxBgJ5Y#R8OSby0u-t-QFBnpnOtdjN3xuiVRvHa4_OEzTwWoGKQ|loras|"
|
| 68 |
+
"mega://https://mega.nz/file/dJJxiSRR#o3XsYfSvb04xg7gNVdfHb3XTVHgvx0ZyXe9N8VQ9Lfw|loras|"
|
| 69 |
+
"mega://https://mega.nz/file/wcAFhRJZ#ifZcckts0wPq1FG693tYLkpFrvjXvab1ZQeL6DuL1T8|loras|"
|
| 70 |
+
"mega://https://mega.nz/file/wNIgmRwb#vn6rKM3QuTDpWVTLEBDsKjIkNkaX2wLKeauKNeVkcFs|loras|"
|
| 71 |
+
"mega://https://mega.nz/file/hZhhhCQS#4je0Im2g1kEvTCuPotjVWkA-g6XICkqMb-mKxMt6R3Y|loras|"
|
| 72 |
+
|
| 73 |
+
# Upscale via Mega.nz (do CODE2)
|
| 74 |
+
"mega://https://mega.nz/file/qdQwAJSC#rPY2Hg4x-_RbHiHUBFW-YU8xZUqPpq5Gpl1uPFiJvW4|upscale_models|"
|
| 75 |
+
"mega://https://mega.nz/file/KIh2marA#CehVNXxQhGfp1bqUL0K1YPWNqrCUoLPCZGq2W6XqmWo|upscale_models|"
|
| 76 |
)
|
| 77 |
|
| 78 |
+
# ===============================
|
| 79 |
+
# Custom nodes (do CODE2)
|
| 80 |
+
# ===============================
|
| 81 |
+
CUSTOM_NODES=(
|
| 82 |
"https://github.com/kijai/ComfyUI-Florence2"
|
| 83 |
"https://github.com/adbrasi/groqrouter"
|
| 84 |
"https://github.com/kijai/ComfyUI-WanVideoWrapper"
|
|
|
|
| 105 |
"https://github.com/grmchn/ComfyUI-ProportionChanger"
|
| 106 |
)
|
| 107 |
|
| 108 |
+
# ===============================
|
| 109 |
+
# Funções de download (mesmas do CODE1, porém download_hf melhorado)
|
| 110 |
+
# ===============================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
download_hf() {
|
| 113 |
+
local url="$1"
|
| 114 |
+
local target_dir="$2"
|
| 115 |
+
local filename="$3"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
+
if [ -n "$filename" ] && [ -f "$target_dir/$filename" ]; then
|
| 118 |
+
log_success "Já existe: $filename"
|
|
|
|
| 119 |
return 0
|
| 120 |
fi
|
| 121 |
|
| 122 |
+
log_info "Baixando HF: ${filename:-$(basename "$url")}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
+
# Se a URL vier com /resolve/, usa HTTP direto (evita problemas com 'hf download')
|
| 125 |
+
if [[ "$url" == *"/resolve/"* ]]; then
|
| 126 |
+
mkdir -p "$target_dir"
|
| 127 |
+
wget -q --show-progress -c -O "$target_dir/$filename" "https://huggingface.co/$url"
|
| 128 |
+
return $?
|
|
|
|
| 129 |
fi
|
| 130 |
|
| 131 |
+
# Parse correto: repo_id = 2 primeiros segmentos; file_path = resto
|
| 132 |
+
local repo_id file_path
|
| 133 |
+
repo_id="$(echo "$url" | cut -d'/' -f1-2)"
|
| 134 |
+
file_path="$(echo "$url" | cut -d'/' -f3-)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
+
if command -v hf >/dev/null 2>&1; then
|
| 137 |
+
mkdir -p "$target_dir"
|
| 138 |
+
(cd "$target_dir" && HF_HUB_ENABLE_HF_TRANSFER=1 hf download "$repo_id" "$file_path" --local-dir . >/dev/null 2>&1) || {
|
| 139 |
+
log_warn "hf download falhou; tentando HTTP"
|
| 140 |
+
wget -q --show-progress -c -O "$target_dir/$filename" "https://huggingface.co/$repo_id/resolve/main/$file_path" || \
|
| 141 |
+
log_error "Download falhou: $filename"
|
| 142 |
+
}
|
| 143 |
+
else
|
| 144 |
+
mkdir -p "$target_dir"
|
| 145 |
+
wget -q --show-progress -c -O "$target_dir/$filename" "https://huggingface.co/$repo_id/resolve/main/$file_path" || \
|
| 146 |
+
log_error "Download falhou: $filename"
|
| 147 |
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
}
|
| 149 |
|
| 150 |
+
download_mega() {
|
| 151 |
local url="$1"
|
| 152 |
local target_dir="$2"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
+
url="${url#mega://}" # remove prefixo
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
+
log_info "Baixando do Mega..."
|
| 157 |
|
| 158 |
+
cd "$target_dir"
|
| 159 |
+
if megadl "$url" 2>/dev/null; then
|
| 160 |
+
log_success "Mega download OK"
|
| 161 |
+
else
|
| 162 |
+
log_warn "Mega download falhou"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
fi
|
| 164 |
+
cd - >/dev/null
|
|
|
|
|
|
|
| 165 |
}
|
| 166 |
|
| 167 |
+
download_file() {
|
| 168 |
local url="$1"
|
| 169 |
local target_dir="$2"
|
| 170 |
+
local filename="$3"
|
| 171 |
|
| 172 |
+
# Adicionar token Civitai se necessário
|
| 173 |
+
if [[ "$url" == *"civitai.com"* ]] && [[ "$url" != *"token="* ]]; then
|
| 174 |
+
url="${url}&token=${CIVITAI_TOKEN}"
|
| 175 |
+
fi
|
| 176 |
|
| 177 |
+
if [ -n "$filename" ] && [ -f "$target_dir/$filename" ]; then
|
| 178 |
+
log_success "Já existe: $filename"
|
| 179 |
+
return 0
|
|
|
|
| 180 |
fi
|
| 181 |
|
| 182 |
+
log_info "Baixando: ${filename:-arquivo}"
|
| 183 |
+
|
| 184 |
+
if command -v aria2c >/dev/null 2>&1; then
|
| 185 |
+
if [ -n "$filename" ]; then
|
| 186 |
+
aria2c -c -x 4 -s 4 --console-log-level=warn --dir="$target_dir" --out="$filename" "$url" || \
|
| 187 |
+
wget -q --show-progress -c -O "$target_dir/$filename" "$url" || \
|
| 188 |
+
log_error "Download falhou: $filename"
|
| 189 |
+
else
|
| 190 |
+
aria2c -c -x 4 -s 4 --console-log-level=warn --dir="$target_dir" "$url" || \
|
| 191 |
+
(cd "$target_dir" && wget -q --show-progress -c "$url") || \
|
| 192 |
+
log_error "Download falhou: $url"
|
| 193 |
fi
|
| 194 |
+
elif [ -n "$filename" ]; then
|
| 195 |
+
wget -q --show-progress -c -O "$target_dir/$filename" "$url" || \
|
| 196 |
+
log_error "Download falhou: $filename"
|
| 197 |
+
else
|
| 198 |
+
(cd "$target_dir" && wget -q --show-progress -c "$url") || \
|
| 199 |
+
log_error "Download falhou: $url"
|
| 200 |
fi
|
|
|
|
|
|
|
|
|
|
| 201 |
}
|
| 202 |
|
| 203 |
process_downloads() {
|
|
|
|
| 204 |
for entry in "${DOWNLOAD_FILES[@]}"; do
|
| 205 |
+
IFS='|' read -r url type filename <<< "$entry"
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
local target_dir="$MODELS_DIR/$type"
|
| 208 |
mkdir -p "$target_dir"
|
| 209 |
|
| 210 |
+
if [[ "$url" == mega://* ]]; then
|
| 211 |
+
download_mega "$url" "$target_dir"
|
| 212 |
+
elif [[ "$url" == *.huggingface.co/* ]]; then
|
| 213 |
+
local hf_path="${url#*huggingface.co/}"
|
| 214 |
+
download_hf "$hf_path" "$target_dir" "$filename"
|
| 215 |
+
else
|
| 216 |
+
download_file "$url" "$target_dir" "$filename"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
fi
|
| 218 |
done
|
|
|
|
|
|
|
| 219 |
}
|
| 220 |
|
| 221 |
+
clone_repo() {
|
| 222 |
local url="$1"
|
| 223 |
local dest="$2"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
+
if [ -d "$dest/.git" ]; then
|
| 226 |
+
git -C "$dest" pull --ff-only 2>/dev/null || true
|
|
|
|
|
|
|
|
|
|
| 227 |
else
|
| 228 |
+
git clone --depth 1 "$url" "$dest" 2>/dev/null || true
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
fi
|
| 230 |
|
| 231 |
+
if [ -f "$dest/requirements.txt" ]; then
|
| 232 |
+
pip install -q -r "$dest/requirements.txt" 2>/dev/null || true
|
|
|
|
|
|
|
| 233 |
fi
|
| 234 |
}
|
| 235 |
|
| 236 |
+
# ========== INSTALAÇÃO ==========
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
|
|
|
|
|
|
|
|
|
|
| 238 |
log_info "========================================="
|
| 239 |
+
log_info " ComfyUI Setup"
|
| 240 |
log_info "========================================="
|
| 241 |
|
| 242 |
+
# 1. Dependências
|
| 243 |
+
log_info "[1/6] Instalando dependências..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
|
| 245 |
+
apt-get update -qq
|
| 246 |
+
apt-get install -y -qq aria2 megatools git wget curl 2>/dev/null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
|
| 248 |
+
pip install --upgrade pip wheel setuptools -q
|
| 249 |
+
pip install --upgrade "huggingface_hub[cli,hf_transfer]" comfy-cli -q
|
|
|
|
| 250 |
|
| 251 |
+
log_success "Dependências instaladas"
|
| 252 |
+
|
| 253 |
+
# 2. ComfyUI
|
| 254 |
+
log_info "[2/6] Instalando ComfyUI..."
|
| 255 |
+
|
| 256 |
+
if [ -f "$COMFY_DIR/main.py" ]; then
|
| 257 |
+
log_warn "ComfyUI já existe"
|
| 258 |
else
|
| 259 |
comfy --skip-prompt install --fast-deps --nvidia
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
fi
|
|
|
|
| 261 |
|
| 262 |
+
log_success "ComfyUI instalado"
|
| 263 |
|
| 264 |
+
# 3. PyTorch CUDA 12.8 (substitui o bloco de Blackwell/5090 do CODE1)
|
| 265 |
+
log_info "[3/6] Instalando PyTorch (CUDA 12.8)..."
|
| 266 |
+
pip install --upgrade torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128 -q
|
| 267 |
+
log_success "PyTorch com CUDA 12.8 instalado"
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
+
# 4. SageAttention (do CODE2)
|
| 270 |
+
log_info "[4/6] Instalando SageAttention..."
|
| 271 |
+
if python3 - <<'PY' 2>/dev/null; then
|
| 272 |
+
import torch, sys
|
| 273 |
+
sys.exit(0 if torch.cuda.is_available() else 1)
|
| 274 |
+
PY
|
| 275 |
+
then
|
| 276 |
+
pip install -q "https://huggingface.co/adbrasi/comfywheel/resolve/main/sageattention-2.2.0-cp311-cp311-linux_x86_64.whl" || log_warn "Falha ao instalar SageAttention"
|
| 277 |
+
if python3 -c 'import sageattention' >/dev/null 2>&1; then
|
| 278 |
+
log_success "SageAttention instalado"
|
| 279 |
+
else
|
| 280 |
+
log_warn "SageAttention não pôde ser importado (seguindo sem)"
|
| 281 |
+
fi
|
| 282 |
else
|
| 283 |
+
log_warn "CUDA não detectada, pulando SageAttention"
|
| 284 |
fi
|
| 285 |
|
| 286 |
+
# 5. Modelos
|
| 287 |
+
log_info "[5/6] Baixando modelos..."
|
| 288 |
+
process_downloads
|
| 289 |
+
log_success "Downloads processados"
|
| 290 |
+
|
| 291 |
+
# 6. Custom nodes
|
| 292 |
+
log_info "[6/6] Instalando custom nodes..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
|
|
|
|
| 294 |
CN_DIR="$COMFY_DIR/custom_nodes"
|
| 295 |
mkdir -p "$CN_DIR"
|
| 296 |
+
|
| 297 |
total_nodes=${#CUSTOM_NODES[@]}
|
| 298 |
current_node=0
|
| 299 |
+
|
| 300 |
for repo in "${CUSTOM_NODES[@]}"; do
|
| 301 |
((current_node++))
|
| 302 |
+
node_name=$(basename "$repo")
|
| 303 |
+
log_info "[$current_node/$total_nodes] Instalando: $node_name"
|
| 304 |
+
clone_repo "$repo" "$CN_DIR/$node_name"
|
| 305 |
done
|
|
|
|
| 306 |
|
| 307 |
+
log_success "Custom nodes instalados"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
|
| 309 |
+
# Iniciar
|
| 310 |
+
log_info "========================================="
|
| 311 |
+
log_success "Instalação concluída!"
|
| 312 |
+
log_info "Iniciando ComfyUI..."
|
| 313 |
+
log_info "URL: http://localhost:$COMFY_PORT"
|
| 314 |
log_info "========================================="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
|
| 316 |
+
cd "$COMFY_DIR"
|
| 317 |
+
|
| 318 |
+
# Habilita SageAttention se presente
|
| 319 |
SAGE_FLAG=""
|
| 320 |
+
if python3 -c 'import sageattention' >/dev/null 2>&1; then
|
|
|
|
|
|
|
| 321 |
SAGE_FLAG="--use-sage-attention"
|
| 322 |
fi
|
| 323 |
|
|
|
|
|
|
|
| 324 |
exec comfy launch -- ${SAGE_FLAG:+$SAGE_FLAG} --listen "$COMFY_HOST" --port "$COMFY_PORT"
|