Spaces:
Paused
Paused
Update start.sh
Browse files
start.sh
CHANGED
|
@@ -3,109 +3,6 @@ set -euo pipefail
|
|
| 3 |
|
| 4 |
: "${APP_DIR:=/app}"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
tree -L 4 /app
|
| 8 |
-
tree -L 4 /data
|
| 9 |
-
|
| 10 |
-
export PYTORCH_CUDA_ALLOC_CONF="expandable_segments:True,max_split_size_mb:128"
|
| 11 |
-
export CUDA_MODULE_LOADING="LAZY"
|
| 12 |
-
|
| 13 |
-
echo "======================================================="
|
| 14 |
-
echo " VINCIE - Start (VINCIE-3B, 8x L40S)"
|
| 15 |
-
echo "======================================================="
|
| 16 |
-
|
| 17 |
-
# 1) Builder (garante Apex/Flash e deps CUDA)
|
| 18 |
-
echo "🛠️ Iniciando o builder.sh para compilar/instalar dependências CUDA..."
|
| 19 |
-
if [ -f "/app/builder.sh" ]; then
|
| 20 |
-
/bin/bash /app/builder.sh
|
| 21 |
-
echo "✅ Builder finalizado."
|
| 22 |
-
else
|
| 23 |
-
echo "⚠️ Aviso: builder.sh não encontrado. Pulando etapa de compilação de dependências."
|
| 24 |
-
fi
|
| 25 |
-
|
| 26 |
-
# 2) Env da UI
|
| 27 |
-
export GRADIO_SERVER_NAME="0.0.0.0"
|
| 28 |
-
export GRADIO_SERVER_PORT="${PORT:-7860}"
|
| 29 |
-
export GRADIO_ENABLE_QUEUE="True"
|
| 30 |
-
|
| 31 |
-
# 3) Preflight: repo + snapshot + symlinks idempotentes
|
| 32 |
-
python3 - <<'PY'
|
| 33 |
-
import os, sys, subprocess
|
| 34 |
-
from pathlib import Path
|
| 35 |
-
from services.vincie import VincieService
|
| 36 |
-
|
| 37 |
-
repo_dir = Path("/app/VINCIE")
|
| 38 |
-
ckpt_repo = repo_dir / "ckpt" / "VINCIE-3B"
|
| 39 |
-
ckpt_app = Path("/app/ckpt") / "VINCIE-3B"
|
| 40 |
-
|
| 41 |
-
def ensure_symlink(link: Path, target: Path):
|
| 42 |
-
if link.is_symlink():
|
| 43 |
-
# relinka se o alvo mudou
|
| 44 |
-
if link.resolve() != target:
|
| 45 |
-
link.unlink()
|
| 46 |
-
link.symlink_to(target, target_is_directory=True)
|
| 47 |
-
elif link.exists():
|
| 48 |
-
# se for pasta/arquivo, remove para padronizar como symlink
|
| 49 |
-
subprocess.run(["rm","-rf",str(link)], check=True)
|
| 50 |
-
link.symlink_to(target, target_is_directory=True)
|
| 51 |
-
else:
|
| 52 |
-
link.parent.mkdir(parents=True, exist_ok=True)
|
| 53 |
-
link.symlink_to(target, target_is_directory=True)
|
| 54 |
-
|
| 55 |
-
# 3.1 baixa repo + snapshot
|
| 56 |
-
svc = VincieService()
|
| 57 |
-
svc.ensure_repo()
|
| 58 |
-
svc.ensure_model()
|
| 59 |
-
snapshot = Path(str(svc.ckpt_dir))
|
| 60 |
-
|
| 61 |
-
# 3.2 cria symlink dentro do repo e também em /app/ckpt
|
| 62 |
-
ensure_symlink(ckpt_repo, snapshot)
|
| 63 |
-
ensure_symlink(ckpt_app, snapshot)
|
| 64 |
-
|
| 65 |
-
# 3.3 valida itens essenciais
|
| 66 |
-
need = [snapshot/"dit.pth", snapshot/"vae.pth", snapshot/"llm14b"]
|
| 67 |
-
missing = [str(p) for p in need if not p.exists()]
|
| 68 |
-
if missing:
|
| 69 |
-
raise SystemExit(f"[preflight] faltam itens no snapshot: {missing}")
|
| 70 |
-
|
| 71 |
-
# 3.4 symlink opcional de models (heranças YAML)
|
| 72 |
-
models_link = Path("/app/models")
|
| 73 |
-
models_src = repo_dir / "models"
|
| 74 |
-
if models_src.exists() and (not models_link.exists()):
|
| 75 |
-
try:
|
| 76 |
-
models_link.symlink_to(models_src, target_is_directory=True)
|
| 77 |
-
print(f"[preflight] linked {models_link} -> {models_src}")
|
| 78 |
-
except Exception as e:
|
| 79 |
-
print("[preflight] warn: link models failed:", e)
|
| 80 |
-
|
| 81 |
-
print(f"[preflight] OK: repo={repo_dir}, ckpt(link)={ckpt_repo} -> {snapshot}")
|
| 82 |
-
PY
|
| 83 |
-
|
| 84 |
-
# 4) PYTHONPATH (imports upstream)
|
| 85 |
-
export VINCIE_DIR="${VINCIE_DIR:-/app/VINCIE}"
|
| 86 |
-
: "${PYTHONPATH:=}"
|
| 87 |
-
if [ -n "${PYTHONPATH}" ]; then
|
| 88 |
-
export PYTHONPATH="${VINCIE_DIR}:${PYTHONPATH}"
|
| 89 |
-
else
|
| 90 |
-
export PYTHONPATH="${VINCIE_DIR}"
|
| 91 |
-
fi
|
| 92 |
-
|
| 93 |
-
# 5) Diagnóstico mínimo
|
| 94 |
-
echo "🔎 ckpt (repo):"
|
| 95 |
-
ls -la /app/VINCIE/ckpt || true
|
| 96 |
-
ls -la /app/VINCIE/ckpt/VINCIE-3B | head -n 20 || true
|
| 97 |
-
echo "🔎 ckpt (/app):"
|
| 98 |
-
ls -la /app/ckpt || true
|
| 99 |
-
ls -la /app/ckpt/VINCIE-3B | head -n 20 || true
|
| 100 |
-
|
| 101 |
-
# 6) Sobe a UI
|
| 102 |
-
echo "🚀 Iniciando a interface web VINCIE (app_vince.py)..."
|
| 103 |
-
cd "$APP_DIR"
|
| 104 |
-
python3 /app/app_vince.py#!/usr/bin/env bash
|
| 105 |
-
set -euo pipefail
|
| 106 |
-
|
| 107 |
-
: "${APP_DIR:=/app}"
|
| 108 |
-
|
| 109 |
export PYTORCH_CUDA_ALLOC_CONF="expandable_segments:True,max_split_size_mb:128"
|
| 110 |
export CUDA_MODULE_LOADING="LAZY"
|
| 111 |
|
|
@@ -127,69 +24,6 @@ export GRADIO_SERVER_NAME="0.0.0.0"
|
|
| 127 |
export GRADIO_SERVER_PORT="${PORT:-7860}"
|
| 128 |
export GRADIO_ENABLE_QUEUE="True"
|
| 129 |
|
| 130 |
-
# 3) Preflight: repo + snapshot + symlinks idempotentes
|
| 131 |
-
python3 - <<'PY'
|
| 132 |
-
import os, sys, subprocess
|
| 133 |
-
from pathlib import Path
|
| 134 |
-
from services.vincie import VincieService
|
| 135 |
-
|
| 136 |
-
repo_dir = Path("/app/VINCIE")
|
| 137 |
-
ckpt_repo = repo_dir / "ckpt" / "VINCIE-3B"
|
| 138 |
-
ckpt_app = Path("/app/ckpt") / "VINCIE-3B"
|
| 139 |
-
|
| 140 |
-
def ensure_symlink(link: Path, target: Path):
|
| 141 |
-
if link.is_symlink():
|
| 142 |
-
# relinka se o alvo mudou
|
| 143 |
-
if link.resolve() != target:
|
| 144 |
-
link.unlink()
|
| 145 |
-
link.symlink_to(target, target_is_directory=True)
|
| 146 |
-
elif link.exists():
|
| 147 |
-
# se for pasta/arquivo, remove para padronizar como symlink
|
| 148 |
-
subprocess.run(["rm","-rf",str(link)], check=True)
|
| 149 |
-
link.symlink_to(target, target_is_directory=True)
|
| 150 |
-
else:
|
| 151 |
-
link.parent.mkdir(parents=True, exist_ok=True)
|
| 152 |
-
link.symlink_to(target, target_is_directory=True)
|
| 153 |
-
|
| 154 |
-
# 3.1 baixa repo + snapshot
|
| 155 |
-
svc = VincieService()
|
| 156 |
-
svc.ensure_repo()
|
| 157 |
-
svc.ensure_model()
|
| 158 |
-
snapshot = Path(str(svc.ckpt_dir))
|
| 159 |
-
|
| 160 |
-
# 3.2 cria symlink dentro do repo e também em /app/ckpt
|
| 161 |
-
ensure_symlink(ckpt_repo, snapshot)
|
| 162 |
-
ensure_symlink(ckpt_app, snapshot)
|
| 163 |
-
|
| 164 |
-
# 3.3 valida itens essenciais
|
| 165 |
-
need = [snapshot/"dit.pth", snapshot/"vae.pth", snapshot/"llm14b"]
|
| 166 |
-
missing = [str(p) for p in need if not p.exists()]
|
| 167 |
-
if missing:
|
| 168 |
-
raise SystemExit(f"[preflight] faltam itens no snapshot: {missing}")
|
| 169 |
-
|
| 170 |
-
# 3.4 symlink opcional de models (heranças YAML)
|
| 171 |
-
models_link = Path("/app/models")
|
| 172 |
-
models_src = repo_dir / "models"
|
| 173 |
-
if models_src.exists() and (not models_link.exists()):
|
| 174 |
-
try:
|
| 175 |
-
models_link.symlink_to(models_src, target_is_directory=True)
|
| 176 |
-
print(f"[preflight] linked {models_link} -> {models_src}")
|
| 177 |
-
except Exception as e:
|
| 178 |
-
print("[preflight] warn: link models failed:", e)
|
| 179 |
-
|
| 180 |
-
print(f"[preflight] OK: repo={repo_dir}, ckpt(link)={ckpt_repo} -> {snapshot}")
|
| 181 |
-
PY
|
| 182 |
-
|
| 183 |
-
# 4) PYTHONPATH (imports upstream)
|
| 184 |
-
export VINCIE_DIR="${VINCIE_DIR:-/app/VINCIE}"
|
| 185 |
-
: "${PYTHONPATH:=}"
|
| 186 |
-
if [ -n "${PYTHONPATH}" ]; then
|
| 187 |
-
export PYTHONPATH="${VINCIE_DIR}:${PYTHONPATH}"
|
| 188 |
-
else
|
| 189 |
-
export PYTHONPATH="${VINCIE_DIR}"
|
| 190 |
-
fi
|
| 191 |
-
|
| 192 |
-
|
| 193 |
|
| 194 |
tree -L 4 /app
|
| 195 |
tree -L 4 /data
|
|
|
|
| 3 |
|
| 4 |
: "${APP_DIR:=/app}"
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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