This tutorial will guide you through installing ComfyUI on an Apple Silicon Mac (M1, M2, M3) with macOS 12.3 or later. The installation will utilize PyTorch’s Metal Performance Shaders (MPS) backend for GPU training acceleration.
Prerequisites
Before starting, ensure you have the following:
- An Apple Silicon Mac (M1, M2, M3)
- macOS 12.3 or later
- Python 3.7 or later
- Xcode command-line tools
Step-by-Step Installation
Step 1: Install Xcode Command-Line Tools
First, install the Xcode command-line tools:
xcode-select --install
Step 2: Install Miniconda
If you don’t already have Miniconda installed, follow the instructions in this guide on installing Conda on Apple Silicon Macs.
Step 3: Create and Activate a Conda Environment
Create a new Conda environment for ComfyUI:
conda create -n comfyui python=3.8
conda activate comfyui
Step 4: Install PyTorch Nightly with MPS Support
Install the latest nightly build of PyTorch with MPS support:
conda install pytorch torchvision torchaudio -c pytorch-nightly
Step 5: Clone the ComfyUI Repository
Clone the ComfyUI repository from GitHub into a directory of your choice:
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
Step 6: Install ComfyUI Dependencies
Install the required Python packages using pip
within the Conda environment:
pip install -r requirements.txt
Step 7: Set Up Models
Create directories for your Stable Diffusion checkpoints and other models:
mkdir -p models/checkpoints models/vae models/embeddings
Downloading Checkpoint Files and VAE Models
1. Hugging Face Model Hub: The Hugging Face Model Hub provides a vast array of models, including Stable Diffusion. You can easily find and download checkpoints and VAE models from the Hugging Face Model Hub.
2. Civitai: Civitai is a popular community platform where users share various Stable Diffusion models and VAEs. You can explore and download the specific models you need from Civitai.
Copy your checkpoint files (e.g., .ckpt
, .safetensors
) and VAE models to the appropriate directories:
# Example commands
cp /path/to/downloaded/model.ckpt models/checkpoints/
cp /path/to/downloaded/model.safetensors models/checkpoints/
cp /path/to/downloaded/vae_model.ckpt models/vae/
Step 8: Run ComfyUI
Launch ComfyUI:
python main.py
Conclusion
By following these steps, you should have ComfyUI installed and running on your Apple Silicon Mac (M1, M2, M3) using the MPS backend for GPU acceleration. This setup ensures efficient performance and leverages the capabilities of your Mac’s hardware for advanced Stable Diffusion workflows.