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:

  1. Apple Silicon Mac: Ensure your Mac has an M1, M2, or newer processor.

  2. macOS Version: Your system should be running macOS 12.3 or later.

  3. Xcode Command Line Tools: Install these by opening Terminal and running:

    bash
    |
    xcode-select --install
  4. 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:

  1. Using Anaconda (Recommended):

    If you don't have Anaconda, download and install it from here.

    For Apple Silicon, open your terminal and run:

    bash
    |
    curl -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:

    bash
    |
    conda create -n comfyui python=3.10 conda activate comfyui

    Then, install PyTorch nightly:

    bash
    |
    conda install pytorch torchvision torchaudio -c pytorch-nightly
  2. Using pip:

    If you prefer pip, you can install PyTorch nightly using:

    bash
    |
    pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu

2. Install ComfyUI

  1. Clone the ComfyUI Repository:

    Open your terminal and clone the ComfyUI repository from GitHub:

    bash
    |
    git clone https://github.com/comfyanonymous/ComfyUI.git
  2. Navigate to the ComfyUI Directory:

    bash
    |
    cd ComfyUI
  3. Install Dependencies:

    Install the required dependencies using pip:

    bash
    |
    pip 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

  1. Stable Diffusion Checkpoints: Place your Stable Diffusion checkpoint files (e.g., .ckpt or .safetensors) in the ComfyUI/models/checkpoints directory.
  2. VAE Models: Put your VAE models in the ComfyUI/models/vae directory.
  3. 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:

bash
|
python 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!