| # Free port 7865, apply local ComfyUI core patches, then start ComfyUI on 7865 | |
| # (with the manager) — DynamicVRAM ENABLED. | |
| kill $(lsof -t -i :7865) 2>/dev/null | |
| # Apply local core patches (fixes the ComfyUI #14573 aimdo/DynamicVRAM sampler | |
| # hang that upstream hasn't merged). Fetch the freshest apply_patches.sh from | |
| # the HF repo (best-effort; keep the local copy if offline), then run it — this | |
| # lets us fix core on an existing image without a rebuild. Applying the patch is | |
| # what makes DynamicVRAM safe here, so no --disable-dynamic-vram is needed. | |
| _p=/workspace/apply_patches.sh | |
| _t=$(mktemp) 2>/dev/null | |
| _tok="${HUGGING_FACE_ACCESS_TOKEN:-${HF_TOKEN:-}}" | |
| _auth=(); [ -n "$_tok" ] && _auth=(-H "Authorization: Bearer $_tok") | |
| if curl -fsSL --connect-timeout 10 --max-time 30 "${_auth[@]}" \ | |
| "https://huggingface.co/aleph65/ComfyUI/raw/main/apply_patches.sh" -o "$_t" 2>/dev/null \ | |
| && head -c2 "$_t" | grep -q '#!'; then | |
| chmod +x "$_t"; mv "$_t" "$_p" | |
| else | |
| rm -f "$_t" | |
| fi | |
| [ -f "$_p" ] && bash "$_p" | |
| cd /workspace/ComfyUI | |
| python main.py --listen 0.0.0.0 --port 7865 --enable-manager | |