Installing ComfyUI on macOS with Apple Silicon
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. This guide will walk you through the process of installing ComfyUI on your macOS device equipped with an Apple Silicon chip (M1, M2, or later).
Prerequisites
Before you begin, make sure you have the following:
Apple Silicon Mac: Ensure your Mac has an M1, M2, or newer processor.
macOS Version: Your system should be running macOS 12.3 or later.
Xcode Command Line Tools: Install these by opening Terminal and running:
bashxcode-select --install
Python: Python 3.7 or later is required. You can check your version using
python3 --version
.
Installation Steps
1. Install PyTorch Nightly
ComfyUI requires the nightly build of PyTorch for optimal performance on Apple Silicon. Follow these steps to install it:
Using Anaconda (Recommended):
If you don't have Anaconda, download and install it from here.
For Apple Silicon, open your terminal and run:
bashcurl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh sh Miniconda3-latest-MacOSX-arm64.sh
Follow the on-screen instructions to complete the Miniconda installation.
After installation, create a new conda environment (optional but recommended) and activate it:
bashconda create -n comfyui python=3.10 conda activate comfyui
Then, install PyTorch nightly:
bashconda install pytorch torchvision torchaudio -c pytorch-nightly
Using pip:
If you prefer pip, you can install PyTorch nightly using:
bashpip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
2. Install ComfyUI
Clone the ComfyUI Repository:
Open your terminal and clone the ComfyUI repository from GitHub:
bashgit clone https://github.com/comfyanonymous/ComfyUI.git
Navigate to the ComfyUI Directory:
bashcd ComfyUI
Install Dependencies:
Install the required dependencies using pip:
bashpip install -r requirements.txt
Note: If you have another Stable Diffusion UI installed and have already installed these dependencies, you might be able to skip this step. However, it's generally recommended to install them in a separate environment for ComfyUI to avoid conflicts.
3. Add Your Models
- Stable Diffusion Checkpoints: Place your Stable Diffusion checkpoint files (e.g.,
.ckpt
or.safetensors
) in theComfyUI/models/checkpoints
directory. - VAE Models: Put your VAE models in the
ComfyUI/models/vae
directory. - LoRAs: Add your LoRA models to the
ComfyUI/models/loras
directory.
4. Run ComfyUI
You're now ready to launch ComfyUI! In your terminal, from the ComfyUI
directory, run:
bashpython main.py
This will start the ComfyUI server, and you should see a URL in your terminal (usually http://127.0.0.1:8188
). Open this URL in your web browser to access the ComfyUI interface.
Troubleshooting
- "MPS device not found" error: If you encounter this error, double-check that you've installed the nightly build of PyTorch and that your macOS version is 12.3 or later.
- Dependency Conflicts: If you run into issues with dependencies, try creating a new virtual environment specifically for ComfyUI and reinstalling the dependencies there.
Conclusion
Congratulations! You have successfully installed ComfyUI on your Apple Silicon Mac. You can now start exploring the node-based interface, loading your models, and creating your own Stable Diffusion workflows.
For further information, you can visit the official ComfyUI GitHub repository or explore the ComfyUI examples page for inspiration. Happy creating!