Skip to content

Instantly share code, notes, and snippets.

@vitorcalvi
Created October 1, 2024 19:47
Show Gist options
  • Save vitorcalvi/ce03407d5d59cb0d6b009d37ae4fb395 to your computer and use it in GitHub Desktop.
Save vitorcalvi/ce03407d5d59cb0d6b009d37ae4fb395 to your computer and use it in GitHub Desktop.
ComfyUI Mac Silicon
#!/bin/bash
set -e
# Install dependencies
brew install llvm libomp [email protected]
# Set up LLVM paths
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
export CC=$(brew --prefix llvm)/bin/clang
export CXX=$(brew --prefix llvm)/bin/clang++
# Clone the ComfyUI repository
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
# Set up Python virtual environment
python3.11 -m venv venv
. ./venv/bin/activate
# Upgrade pip and install PyTorch with MPS support
pip install --upgrade pip
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/mps
# Install necessary packages
pip install --no-binary :all: numpy
pip install "diffusers[torch]"
pip install tensorflow tensorflow-metal
pip install onnxruntime onnxruntime-silicon
pip install jax-metal
pip install mlx coremltools
# Install required packages from requirements.txt
pip install -r requirements.txt
pip install wheel
pip install xformers
# Clone the custom nodes manager
cd custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git
cd ..
# Install extras for some nodes
pip install --upgrade onnx transformers optimum omegaconf
# For ComfyUI_VLM_nodes, install llama-cpp-python
pip install llama-cpp-python
# For prompt_generator nodes, install tf-keras
pip install tf-keras
# Modify the version of py-cpuinfo to avoid arm64 issues (if the file exists)
if [ -f "ComfyUI_VLM_nodes/requirements.txt" ]; then
sed -i .orig 's/py-cpuinfo==.*/py-cpuinfo==9/' ComfyUI_VLM_nodes/requirements.txt
else
echo "Warning: ComfyUI_VLM_nodes/requirements.txt not found, skipping sed modification."
fi
# Start the application with MPS backend (if applicable)
echo "Launching ComfyUI with MPS backend..."
python main.py --force-fp16 --fp16-vae --highvram
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment