Skip to content

Instantly share code, notes, and snippets.

@vitorcalvi
Last active December 12, 2025 09:59
Show Gist options
  • Select an option

  • Save vitorcalvi/ce03407d5d59cb0d6b009d37ae4fb395 to your computer and use it in GitHub Desktop.

Select an option

Save vitorcalvi/ce03407d5d59cb0d6b009d37ae4fb395 to your computer and use it in GitHub Desktop.
ComfyUI Mac Silicon
#!/usr/bin/env bash
set -euo pipefail
# 1. Configuration
# FIXED: Changed back to $HOME/ComfyUI to match your running instance in the logs
COMFY_DIR="${COMFY_DIR:-$HOME/ComfyUI}"
pick_python () {
# A) User override
if [[ -n "${PYTHON_BIN:-}" ]] && command -v "$PYTHON_BIN" >/dev/null 2>&1; then
echo "$PYTHON_BIN"; return
fi
# B) Prefer newest installed versions
for p in python3.12 python3.11 python3.10; do
if command -v "$p" >/dev/null 2>&1; then
echo "$p"; return
fi
done
# C) Try Homebrew paths (Apple Silicon)
for p in /opt/homebrew/opt/python@3.11/bin/python3.11 /usr/local/opt/python@3.11/bin/python3.11; do
if [[ -x "$p" ]]; then
echo "$p"; return
fi
done
echo ""
}
PYTHON_BIN="$(pick_python)"
if [[ -z "$PYTHON_BIN" ]]; then
echo "ERROR: Python >= 3.10 not found."
echo "Install it with: brew install python@3.11"
exit 1
fi
echo "== ComfyUI macOS (Apple Silicon) Launcher & Updater =="
echo "Target dir: $COMFY_DIR"
echo "Using Python: $PYTHON_BIN"
echo
# 2. Pre-flight Checks
ARCH="$(uname -m)"
if [[ "$ARCH" != "arm64" ]]; then
echo "ERROR: Run in native arm64 Terminal (not Rosetta). Current: $ARCH"
exit 1
fi
if ! xcode-select -p >/dev/null 2>&1; then
echo "ERROR: Xcode Command Line Tools missing. Run: xcode-select --install"
exit 1
fi
# 3. Clone / Update ComfyUI
if [[ -d "$COMFY_DIR/.git" ]]; then
echo "Updating ComfyUI..."
git -C "$COMFY_DIR" pull --rebase
else
echo "Cloning ComfyUI..."
git clone https://github.com/comfyanonymous/ComfyUI.git "$COMFY_DIR"
fi
cd "$COMFY_DIR"
# 4. Virtual Environment
if [[ ! -d venv ]]; then
echo "Creating venv..."
"$PYTHON_BIN" -m venv venv
fi
# shellcheck disable=SC1091
source venv/bin/activate
echo "Installing/Updating Dependencies..."
python -m pip install -U pip setuptools wheel
# PyTorch (MPS/Metal support)
python -m pip install -U torch torchvision torchaudio
# ComfyUI deps
python -m pip install -r requirements.txt
# 5. ComfyUI Manager
mkdir -p custom_nodes
if [[ -d custom_nodes/ComfyUI-Manager/.git ]]; then
git -C custom_nodes/ComfyUI-Manager pull --rebase
else
git clone https://github.com/ltdrdata/ComfyUI-Manager.git custom_nodes/ComfyUI-Manager
fi
# 6. llama-cpp-python (Metal Compilation)
echo "Installing llama-cpp-python (Metal)..."
export PYTORCH_ENABLE_MPS_FALLBACK=1
unset CC CXX
export CMAKE_OSX_ARCHITECTURES=arm64
CMAKE_ARGS="-DGGML_METAL=ON -DLLAMA_METAL=ON" FORCE_CMAKE=1 \
python -m pip install -U --no-cache-dir llama-cpp-python
# 7. Model Downloads (Post-Install)
# This section downloads the missing files from your screenshot
echo
echo "== Checking/Downloading Models =="
download_if_missing() {
local url="$1"
local dest="$2"
local dir
dir=$(dirname "$dest")
mkdir -p "$dir"
if [[ ! -f "$dest" ]]; then
echo " -> Downloading missing model: $dest"
# -C - resumes; -f fails on 404; -L follows redirects
curl -fL --retry 3 -C - -o "$dest" "$url"
else
echo " -> Found: $dest"
fi
}
# Kandinsky 5 I2V (diffusion_models)
download_if_missing \
"https://huggingface.co/kandinskylab/Kandinsky-5.0-I2V-Lite-5s/resolve/main/model/kandinsky5lite_i2v_5s.safetensors" \
"models/diffusion_models/kandinsky5lite_i2v_5s.safetensors"
# Hunyuan VAE (vae)
download_if_missing \
"https://huggingface.co/Kijai/HunyuanVideo_comfy/resolve/main/hunyuan_video_vae_bf16.safetensors" \
"models/vae/hunyuan_video_vae_bf16.safetensors"
# Qwen Text Encoder (text_encoders)
download_if_missing \
"https://huggingface.co/Comfy-Org/HunyuanVideo_1.5_repackaged/resolve/main/split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors" \
"models/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors"
# CLIP L (text_encoders)
download_if_missing \
"https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors" \
"models/text_encoders/clip_l.safetensors"
echo
echo "== Ready =="
echo "Launching ComfyUI: http://127.0.0.1:8188"
python main.py --force-fp16 --use-split-cross-attention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment