Spaces:
Paused
Paused
Update start.sh
Browse files
start.sh
CHANGED
|
@@ -9,14 +9,19 @@ echo "======================================================="
|
|
| 9 |
export CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-0,1,2,3,4,5,6,7}"
|
| 10 |
export TORCH_DTYPE="${TORCH_DTYPE:-bfloat16}"
|
| 11 |
|
| 12 |
-
# SDPA/FA toggles
|
| 13 |
export ENABLE_FLASH_SDP="${ENABLE_FLASH_SDP:-1}"
|
| 14 |
export ENABLE_MEMORY_EFFICIENT_SDP="${ENABLE_MEMORY_EFFICIENT_SDP:-1}"
|
| 15 |
export ENABLE_MATH_SDP="${ENABLE_MATH_SDP:-0}"
|
| 16 |
export FLASH_ATTENTION_DISABLE="${FLASH_ATTENTION_DISABLE:-0}"
|
| 17 |
export XFORMERS_FORCE_DISABLE="${XFORMERS_FORCE_DISABLE:-1}"
|
| 18 |
|
| 19 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
export CUDA_MODULE_LOADING="${CUDA_MODULE_LOADING:-LAZY}"
|
| 21 |
export CUDA_DEVICE_MAX_CONNECTIONS="${CUDA_DEVICE_MAX_CONNECTIONS:-32}"
|
| 22 |
export CUDA_DEVICE_ORDER="${CUDA_DEVICE_ORDER:-PCI_BUS_ID}"
|
|
@@ -27,91 +32,22 @@ export NCCL_DEBUG="${NCCL_DEBUG:-INFO}"
|
|
| 27 |
export NCCL_ASYNC_ERROR_HANDLING="${NCCL_ASYNC_ERROR_HANDLING:-1}"
|
| 28 |
export NCCL_P2P_DISABLE="${NCCL_P2P_DISABLE:-0}"
|
| 29 |
export NCCL_IB_DISABLE="${NCCL_IB_DISABLE:-1}"
|
| 30 |
-
export
|
| 31 |
-
export
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
export APP_HOME="${APP_HOME:-/app}"
|
| 35 |
export HF_HOME="${HF_HOME:-/app/.cache/huggingface}"
|
| 36 |
-
|
| 37 |
-
export TRANSFORMERS_CACHE="${TRANSFORMERS_CACHE:-/app/.cache/transformers}"
|
| 38 |
-
export DIFFUSERS_CACHE="${DIFFUSERS_CACHE:-/app/.cache/diffusers}"
|
| 39 |
-
export TORCH_HOME="${TORCH_HOME:-/app/.cache/torch}"
|
| 40 |
-
export HF_HUB_ENABLE_HF_TRANSFER="${HF_HUB_ENABLE_HF_TRANSFER:-1}"
|
| 41 |
-
export TOKENIZERS_PARALLELISM="${TOKENIZERS_PARALLELISM:-false}"
|
| 42 |
-
export MODELS_DIR="${MODELS_DIR:-/app/models}"
|
| 43 |
-
|
| 44 |
-
mkdir -p /app/.cache/torch /app/.cache/huggingface /app/.cache/datasets /app/.cache/transformers /app/.cache/diffusers || true
|
| 45 |
-
mkdir -p /home/user/.cache/models || true
|
| 46 |
-
[ -L /app/models ] || ln -sf /home/user/.cache/models /app/models || true
|
| 47 |
-
|
| 48 |
-
# ---------------------- Diagnóstico ----------------------
|
| 49 |
-
nvidia-smi || true
|
| 50 |
-
python - <<'PY' || true
|
| 51 |
-
import torch, os
|
| 52 |
-
print("Torch:", torch.__version__)
|
| 53 |
-
print("CUDA available:", torch.cuda.is_available())
|
| 54 |
-
print("Num GPUs:", torch.cuda.device_count())
|
| 55 |
-
print("MemEff SDP:", os.getenv("ENABLE_MEMORY_EFFICIENT_SDP"))
|
| 56 |
-
print("Math SDP:", os.getenv("ENABLE_MATH_SDP"))
|
| 57 |
-
print("FA disable:", os.getenv("FLASH_ATTENTION_DISABLE"))
|
| 58 |
-
print("Dtype:", os.getenv("TORCH_DTYPE"))
|
| 59 |
-
PY
|
| 60 |
-
|
| 61 |
-
# ---------------------- Builder (Apex + Q8) ----------------------
|
| 62 |
-
# Executa com GPU disponível; busca wheels no HF e compila se necessário (sem FlashAttention)
|
| 63 |
-
if nvidia-smi >/dev/null 2>&1; then
|
| 64 |
-
if [ "${DISABLE_BUILDER:-0}" = "0" ]; then
|
| 65 |
-
echo "🔧 Executando builder (Apex + Q8)..."
|
| 66 |
-
chmod +x /app/builder.sh || true
|
| 67 |
-
# Configuráveis:
|
| 68 |
-
SELF_HF_REPO_ID="carlex3321/aduc-sdr" # repo de wheels no HF
|
| 69 |
-
HF_UPLOAD_WHEELS=1 # publica wheels geradas
|
| 70 |
-
BUILDER_TIMEOUT_SEC=6000000 # tempo limite
|
| 71 |
-
#Q8_REPO / Q8_COMMIT # pin do LTX Q8
|
| 72 |
-
( timeout ${BUILDER_TIMEOUT_SEC:-60000} bash -lc "/app/builder.sh" ) || {
|
| 73 |
-
echo "⚠️ Builder excedeu tempo/retornou erro; prosseguindo com a aplicação."
|
| 74 |
-
}
|
| 75 |
-
else
|
| 76 |
-
echo "ℹ️ Builder desabilitado por DISABLE_BUILDER=1"
|
| 77 |
-
fi
|
| 78 |
-
else
|
| 79 |
-
echo "⚠️ GPU não visível; pulando builder (Apex/Q8)."
|
| 80 |
-
fi
|
| 81 |
-
|
| 82 |
-
# ---------------------- Verificação dos modelos ----------------------
|
| 83 |
-
echo "🔍 Verificando a integridade dos modelos..."
|
| 84 |
-
#[ -x "./setup/vince.sh" ] && ./setup/vince.sh || bash ./setup/vince.sh || true
|
| 85 |
-
#[ -x "./setup/seedvr.sh" ] && ./setup/seedvr.sh || bash ./setup/seedvr.sh || true
|
| 86 |
-
#[ -x "./setup/ltx.sh" ] && ./setup/ltx.sh || bash ./setup/ltx.sh || true
|
| 87 |
-
echo "✅ Modelos verificados."
|
| 88 |
-
|
| 89 |
-
# ---------------------- Preferências Diffusers ----------------------
|
| 90 |
-
export DIFFUSERS_ATTENTION_IMPLEMENTATION="${DIFFUSERS_ATTENTION_IMPLEMENTATION:-sdpa}" # flash opcional
|
| 91 |
-
export DIFFUSERS_USE_TORCH_SDPA="${DIFFUSERS_USE_TORCH_SDPA:-1}"
|
| 92 |
-
export DIFFUSERS_ENABLE_CPU_OFFLOAD="${DIFFUSERS_ENABLE_CPU_OFFLOAD:-0}"
|
| 93 |
-
export DIFFUSERS_ENABLE_TORCH_COMPILE="${DIFFUSERS_ENABLE_TORCH_COMPILE:-0}"
|
| 94 |
-
export DIFFUSERS_SDP_KERNEL_FALLBACK="${DIFFUSERS_SDP_KERNEL_FALLBACK:-sdpa}"
|
| 95 |
-
|
| 96 |
-
# ---------------------- Lançamento da aplicação ----------------------
|
| 97 |
-
PORT="${PORT:-7860}"
|
| 98 |
-
OPTS="--server.port $PORT --server.name 0.0.0.0 --theme Default --allowed-paths /app/outputs,/app/ckpt"
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
chmod +x /app/info.sh || true
|
| 102 |
-
bash -lc "/app/info.sh"
|
| 103 |
|
|
|
|
|
|
|
| 104 |
|
| 105 |
-
|
| 106 |
|
|
|
|
|
|
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
echo "🚀 Subindo SeedVR Refine..."
|
| 111 |
-
python app_seedvr.py $OPTS
|
| 112 |
-
;;
|
| 113 |
-
vince|*)
|
| 114 |
-
echo "🚀 Subindo VINCIE..."
|
| 115 |
-
python app_vince.py $OPTS
|
| 116 |
-
;;
|
| 117 |
-
esac
|
|
|
|
| 9 |
export CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-0,1,2,3,4,5,6,7}"
|
| 10 |
export TORCH_DTYPE="${TORCH_DTYPE:-bfloat16}"
|
| 11 |
|
| 12 |
+
# SDPA/FA toggles
|
| 13 |
export ENABLE_FLASH_SDP="${ENABLE_FLASH_SDP:-1}"
|
| 14 |
export ENABLE_MEMORY_EFFICIENT_SDP="${ENABLE_MEMORY_EFFICIENT_SDP:-1}"
|
| 15 |
export ENABLE_MATH_SDP="${ENABLE_MATH_SDP:-0}"
|
| 16 |
export FLASH_ATTENTION_DISABLE="${FLASH_ATTENTION_DISABLE:-0}"
|
| 17 |
export XFORMERS_FORCE_DISABLE="${XFORMERS_FORCE_DISABLE:-1}"
|
| 18 |
|
| 19 |
+
# Triton.ops legacy off / BNB off
|
| 20 |
+
export BNB_DISABLE=1
|
| 21 |
+
export BITSANDBYTES_DISABLE=1
|
| 22 |
+
export LOAD_IN_8BIT=0
|
| 23 |
+
|
| 24 |
+
# CUDA/NCCL/perf — single-node robust
|
| 25 |
export CUDA_MODULE_LOADING="${CUDA_MODULE_LOADING:-LAZY}"
|
| 26 |
export CUDA_DEVICE_MAX_CONNECTIONS="${CUDA_DEVICE_MAX_CONNECTIONS:-32}"
|
| 27 |
export CUDA_DEVICE_ORDER="${CUDA_DEVICE_ORDER:-PCI_BUS_ID}"
|
|
|
|
| 32 |
export NCCL_ASYNC_ERROR_HANDLING="${NCCL_ASYNC_ERROR_HANDLING:-1}"
|
| 33 |
export NCCL_P2P_DISABLE="${NCCL_P2P_DISABLE:-0}"
|
| 34 |
export NCCL_IB_DISABLE="${NCCL_IB_DISABLE:-1}"
|
| 35 |
+
export NCCL_SOCKET_IFNAME="${NCCL_SOCKET_IFNAME:-lo}"
|
| 36 |
+
export NCCL_BLOCKING_WAIT=1
|
| 37 |
+
export TORCH_NCCL_BLOCKING_WAIT=1
|
| 38 |
+
export NCCL_TIMEOUT="${NCCL_TIMEOUT:-600}"
|
| 39 |
|
| 40 |
+
# HF caches
|
|
|
|
| 41 |
export HF_HOME="${HF_HOME:-/app/.cache/huggingface}"
|
| 42 |
+
unset TRANSFORMERS_CACHE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
# ---------------------- Banner ----------------------
|
| 45 |
+
./info.sh || true
|
| 46 |
|
| 47 |
+
echo "🚀 Subindo serviços..."
|
| 48 |
|
| 49 |
+
# Exemplo: subir UI mínima SD Img2Img (ajuste conforme seu app)
|
| 50 |
+
# python app/app_animatediff_min.py
|
| 51 |
|
| 52 |
+
# Ou subir VINCIE UI se for o caso
|
| 53 |
+
python app/app_vince.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|