Running ComfyUI on Mac
Setting up ComfyUI on a Mac requires a few specific steps, especially around managing dependencies and ensuring compatibility with Apple’s Metal acceleration. Here’s a detailed walkthrough of what worked for me.
Prerequisites: Python Compatibility
ComfyUI requires Python 3.10 or lower; using a newer Python version can lead to errors, particularly when building the wheel for Hugging Face’s tokenizers
. In my setup, I specified python310
through Nix to avoid conflicts.
Note: If you also have Homebrew installed, be aware that it may default to Python 3 for other packages. Homebrew’s Python can override your setup, so it’s worth double-checking that you’re running the correct Python version. Until I fully streamline my environment, I’m mindful of which Python is active and its version.
Verify your Python path and version as follows:
which python
# Output: ~/.nix-profile/bin/python
python --version
# Output: Python 3.10.15
Step 1: Set Up a Virtual Environment
With the correct Python version confirmed, begin by cloning the ComfyUI repository and setting up a virtual environment to isolate dependencies.
git clone https://github.com/comfyanonymous/ComfyUI
cd ComfyUI
python -m venv venv
Step 2: Enable Metal Acceleration
To optimize performance on Mac, we can use Metal acceleration, which accelerates PyTorch computations using Apple’s GPU framework. The feature is still in beta, so installing these packages requires some additional options.
Activate the virtual environment: Make sure you’re using the
venv
created in the previous step.Install PyTorch with Metal acceleration: Run the following to install nightly versions of PyTorch with Metal support.
./venv/bin/pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
Install ComfyUI dependencies: Now, install the required packages for ComfyUI.
./venv/bin/pip install -r requirements.txt
Step 3: Run ComfyUI
With dependencies installed, you’re ready to launch ComfyUI.
./venv/bin/python main.py
And that’s it! You should now have ComfyUI running smoothly on your Mac with Metal acceleration. If any issues arise, revisit the Python version setup, as compatibility is key here.
Published on:
Last modified: