Introduction
ComfyUI is a powerful and modular GUI and backend for working with diffusion models, offering a node-based interface for creating complex Stable Diffusion workflows. Unlike some other UIs that hide the complexity, ComfyUI gives you granular control over the generation process.
This guide will walk you through the process of installing ComfyUI on your macOS device equipped with an Apple Silicon chip (M1, M2, M3, or later), utilizing Apple's Metal Performance Shaders (MPS) for hardware acceleration.
Prerequisites
Before you begin, make sure you have the following:
- Apple Silicon Mac: An M1, M2, M3, or newer processor.
- macOS Version: macOS 12.3 (Monterey) or later is required for MPS support.
- Xcode Command Line Tools: Essential for compiling dependencies. Install them by opening Terminal and running:
xcode-select --install - Python: Python 3.10 or later is recommended.
Installation Steps
Unlike Windows, there isn't a "one-click" portable package for macOS yet, but the manual installation is straightforward.
1. Set Up a Virtual Environment (Recommended)
It is highly recommended to use a virtual environment to keep your dependencies isolated.
Using Conda (Miniconda):
If you don't have Conda, install Miniconda first.
# Create a new environment named 'comfyui' with Python 3.10
conda create -n comfyui python=3.10
# Activate the environment
conda activate comfyui
Using venv (Standard Python):
# Create a virtual environment in a folder named 'comfy-env'
python3 -m venv comfy-env
# Activate the environment
source comfy-env/bin/activate
2. Install PyTorch Nightly with MPS Support
ComfyUI on macOS runs best on the nightly build of PyTorch, which contains the latest fixes and performance improvements for Apple Silicon (MPS).
Run the following command in your terminal (with your environment activated):
pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
Note: Even though the URL says cpu, this build includes the necessary MPS support for macOS.
3. Install ComfyUI
Clone the Repository: Download the ComfyUI code from GitHub.
git clone https://github.com/comfyanonymous/ComfyUI.gitNavigate to the Directory:
cd ComfyUIInstall Requirements: Install the rest of the Python dependencies needed for ComfyUI.
pip install -r requirements.txt
4. Add Your Models
Before you can generate anything, you need models.
- Checkpoints: Download Stable Diffusion checkpoints (e.g.,
v1-5-pruned-emaonly.ckptor SDXL.safetensorsfiles) and place them in:ComfyUI/models/checkpoints/ - VAE: (Optional but recommended) Place VAE models in:
ComfyUI/models/vae/ - LoRAs: Place LoRA models in:
ComfyUI/models/loras/
5. Run ComfyUI
You are now ready to launch!
python main.py
- Launch: The terminal will show a local URL, typically
http://127.0.0.1:8188. - Force FP16 (Optional): If you are low on RAM or want slightly faster performance at the cost of precision, you can try:
python main.py --force-fp16
Verification
To ensure your Mac's GPU is being used, keep an eye on the terminal when you first run a generation. You shouldn't see errors about "CPU fallback" for core operations.
You can also run this quick Python snippet to confirm MPS is active:
import torch
if torch.backends.mps.is_available():
print("Success: MPS (Metal) is available!")
else:
print("Error: MPS not found.")
Troubleshooting
- "MPS device not found": Ensure you are on macOS 12.3+ and installed the nightly version of PyTorch as shown in Step 2. Standard
pip install torchmight install an older stable version without full MPS support. - Slow Performance: Ensure you are not running out of RAM (swapping). Closing other apps helps. Also, check if you are using
--force-fp16if your results are too slow. For issues related to ComfyUI crashing on Mac when processing large images, refer to this article: ComfyUI crashing on Mac with big images.
Conclusion
You have successfully installed ComfyUI on your Apple Silicon Mac! You can now harness the power of your M-series chip to build intricate AI art pipelines.
For the latest updates, always check the official ComfyUI GitHub. Happy creating!
