adbrasi commited on
Commit
8a2fc0f
·
verified ·
1 Parent(s): 80237ea

Update setup_comfyui_wan22.sh

Browse files
Files changed (1) hide show
  1. setup_comfyui_wan22.sh +54 -63
setup_comfyui_wan22.sh CHANGED
@@ -348,8 +348,23 @@ log_info "[5/8] Baixando ControlNet Union..."
348
  "diffusion_pytorch_model_promax.safetensors"
349
 
350
  log_debug "Copiando ControlNet para $MODELS_DIR/controlnet..."
351
- cp -fv "$TMPDL/controlnet/diffusion_pytorch_model_promax.safetensors" \
352
- "$MODELS_DIR/controlnet/controlnet-union.safetensors"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
 
354
  log_success " ControlNet baixado"
355
  ) &
@@ -366,43 +381,37 @@ log_info "[6/8] Baixando modelo do Civitai..."
366
  CIVITAI_URL="https://civitai.com/api/download/models/2122278?type=Model&format=SafeTensor&size=pruned&fp=fp16&token=${CIVITAI_TOKEN}"
367
 
368
  log_debug "Baixando de: $CIVITAI_URL"
369
- log_cmd "wget --content-disposition \"$CIVITAI_URL\""
370
-
371
- # Tentar com wget primeiro (melhor para nomes de arquivo)
372
- # Não suprimir output para ver o progresso
373
- if ! wget --content-disposition \
374
- --tries=3 \
375
- --timeout=60 \
376
- --continue \
377
- --progress=bar:force \
378
- "$CIVITAI_URL"; then
379
-
380
- log_warn " Wget falhou, tentando com curl..."
381
-
382
- # Tentar obter o nome do arquivo do header primeiro
383
- FILENAME=$(curl -sI -L "$CIVITAI_URL" | grep -i "content-disposition" | sed -n 's/.*filename="\([^"]*\)".*/\1/p')
384
-
385
- if [ -z "$FILENAME" ]; then
386
- # Se não conseguir detectar, usar nome genérico
387
- FILENAME="civitai_model_$(date +%s).safetensors"
388
- log_warn "Não foi possível detectar nome do arquivo, usando: $FILENAME"
389
- else
390
- log_debug "Nome do arquivo detectado: $FILENAME"
391
- fi
392
-
393
- log_cmd "curl -L \"$CIVITAI_URL\" -o \"$FILENAME\""
394
- curl -L \
395
- --retry 3 \
396
- --connect-timeout 30 \
397
- --progress-bar \
398
- -o "$FILENAME" \
399
- "$CIVITAI_URL"
400
  fi
401
 
402
- # Verificar se algum arquivo foi baixado
403
- DOWNLOADED_FILE=$(ls -t *.safetensors 2>/dev/null | head -n1)
404
- if [ -n "$DOWNLOADED_FILE" ]; then
405
- log_success " Modelo Civitai baixado: $DOWNLOADED_FILE"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  else
407
  log_error " Falha ao baixar modelo Civitai"
408
  fi
@@ -423,9 +432,9 @@ log_info "[7/8] Preparando SageAttention (paralelo com downloads)..."
423
  log_cmd "python3 -m pip install \"triton>=3.0.0\""
424
  python3 -m pip install "triton>=3.0.0"
425
 
426
- # Instalar pynvml para melhor detecção de GPU
427
- log_cmd "python3 -m pip install pynvml"
428
- python3 -m pip install pynvml || true
429
 
430
  # Clonar SageAttention
431
  SAGE_DIR="$TMPDL/SageAttention"
@@ -442,21 +451,9 @@ log_info "[7/8] Preparando SageAttention (paralelo com downloads)..."
442
 
443
  # Mostrar output completo da compilação
444
  log_cmd "python3 setup.py install"
445
- python3 setup.py install
446
 
447
- # Testar se instalou
448
- if python3 -c "import sageattention" 2>/dev/null; then
449
- log_success " SageAttention instalado com sucesso"
450
-
451
- # Mostrar informações sobre a instalação
452
- python3 -c "
453
- import sageattention
454
- print(f' SageAttention version: {sageattention.__version__ if hasattr(sageattention, \"__version__\") else \"unknown\"}')
455
- print(f' SageAttention path: {sageattention.__file__}')
456
- " 2>/dev/null || true
457
- else
458
- log_warn " SageAttention não foi instalado corretamente"
459
- fi
460
  else
461
  log_warn " CUDA não detectado, pulando SageAttention"
462
  fi
@@ -559,15 +556,9 @@ if [ $ERROR_COUNT -eq 0 ]; then
559
  log_success "Instalação concluída com sucesso!"
560
  log_info "ComfyUI instalado em: $COMFY_DIR"
561
 
562
- # Verificar se SageAttention está disponível
563
- SAGE_FLAG=""
564
- if python3 -c "import sageattention" 2>/dev/null; then
565
- SAGE_FLAG="--use-sage-attention"
566
- log_success "SageAttention disponível (compilado com MAX_JOBS=$MAX_JOBS)"
567
- else
568
- SAGE_FLAG="--use-sage-attention"
569
- log_info "SageAttention não disponível"
570
- fi
571
 
572
  # Mostrar informações do sistema
573
  log_debug "Configuração final:"
 
348
  "diffusion_pytorch_model_promax.safetensors"
349
 
350
  log_debug "Copiando ControlNet para $MODELS_DIR/controlnet..."
351
+ # O arquivo pode estar direto no diretório ou em subdiretório
352
+ if [ -f "$TMPDL/controlnet/diffusion_pytorch_model_promax.safetensors" ]; then
353
+ cp -fv "$TMPDL/controlnet/diffusion_pytorch_model_promax.safetensors" \
354
+ "$MODELS_DIR/controlnet/controlnet-union.safetensors"
355
+ elif [ -f "$TMPDL/xinsir/controlnet-union-sdxl-1.0/diffusion_pytorch_model_promax.safetensors" ]; then
356
+ cp -fv "$TMPDL/xinsir/controlnet-union-sdxl-1.0/diffusion_pytorch_model_promax.safetensors" \
357
+ "$MODELS_DIR/controlnet/controlnet-union.safetensors"
358
+ else
359
+ # Procurar o arquivo em qualquer lugar do diretório temporário
360
+ FOUND_FILE=$(find "$TMPDL" -name "diffusion_pytorch_model_promax.safetensors" -type f | head -n1)
361
+ if [ -n "$FOUND_FILE" ]; then
362
+ log_debug "ControlNet encontrado em: $FOUND_FILE"
363
+ cp -fv "$FOUND_FILE" "$MODELS_DIR/controlnet/controlnet-union.safetensors"
364
+ else
365
+ log_warn "ControlNet não encontrado no diretório temporário"
366
+ fi
367
+ fi
368
 
369
  log_success " ControlNet baixado"
370
  ) &
 
381
  CIVITAI_URL="https://civitai.com/api/download/models/2122278?type=Model&format=SafeTensor&size=pruned&fp=fp16&token=${CIVITAI_TOKEN}"
382
 
383
  log_debug "Baixando de: $CIVITAI_URL"
384
+
385
+ # Usar curl direto pois wget está falhando com nomes longos
386
+ # Primeiro obter o nome real do arquivo
387
+ log_debug "Obtendo nome do arquivo..."
388
+ HEADERS=$(curl -sI -L --max-time 30 "$CIVITAI_URL")
389
+ FILENAME=$(echo "$HEADERS" | grep -i "content-disposition" | sed -n 's/.*filename="\([^"]*\)".*/\1/p' | tr -d '\r')
390
+
391
+ if [ -z "$FILENAME" ]; then
392
+ # Tentar outro padrão de header
393
+ FILENAME=$(echo "$HEADERS" | grep -i "content-disposition" | sed -n "s/.*filename='\([^']*\)'.*/\1/p" | tr -d '\r')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
  fi
395
 
396
+ if [ -z "$FILENAME" ]; then
397
+ # Se ainda não conseguiu, usar nome padrão baseado no ID do modelo
398
+ FILENAME="civitai_model_2122278.safetensors"
399
+ log_warn "Não foi possível detectar nome do arquivo, usando: $FILENAME"
400
+ else
401
+ log_success "Nome do arquivo detectado: $FILENAME"
402
+ fi
403
+
404
+ # Baixar o arquivo
405
+ log_cmd "curl -L --progress-bar \"$CIVITAI_URL\" -o \"$FILENAME\""
406
+
407
+ if curl -L \
408
+ --retry 3 \
409
+ --connect-timeout 60 \
410
+ --max-time 1800 \
411
+ --progress-bar \
412
+ -o "$FILENAME" \
413
+ "$CIVITAI_URL"; then
414
+ log_success " Modelo Civitai baixado: $FILENAME"
415
  else
416
  log_error " Falha ao baixar modelo Civitai"
417
  fi
 
432
  log_cmd "python3 -m pip install \"triton>=3.0.0\""
433
  python3 -m pip install "triton>=3.0.0"
434
 
435
+ # Instalar pynvml para melhor detecção de GPU (ignorar warning de deprecation)
436
+ log_cmd "python3 -m pip install nvidia-ml-py"
437
+ python3 -m pip install nvidia-ml-py 2>&1 | grep -v "FutureWarning" || true
438
 
439
  # Clonar SageAttention
440
  SAGE_DIR="$TMPDL/SageAttention"
 
451
 
452
  # Mostrar output completo da compilação
453
  log_cmd "python3 setup.py install"
454
+ python3 setup.py install 2>&1 | grep -v "SetuptoolsDeprecationWarning" | grep -v "FutureWarning" || true
455
 
456
+ log_success " SageAttention instalado"
 
 
 
 
 
 
 
 
 
 
 
 
457
  else
458
  log_warn " CUDA não detectado, pulando SageAttention"
459
  fi
 
556
  log_success "Instalação concluída com sucesso!"
557
  log_info "ComfyUI instalado em: $COMFY_DIR"
558
 
559
+ # Sempre usar flag do SageAttention (ComfyUI ignora se não estiver instalado)
560
+ SAGE_FLAG="--use-sage-attention"
561
+ log_info "Flag SageAttention habilitada (será usada se disponível)"
 
 
 
 
 
 
562
 
563
  # Mostrar informações do sistema
564
  log_debug "Configuração final:"