Agentic Research

Deploying ComfyUI on Mac M2: A Record of Pitfalls

2026/04/2013 min readBryan Chan閱讀中文原文
TopicsMacPitfalls

Environment

  • MacBook Pro M2 Max, 32GB RAM
  • macOS 15 Sequoia
  • Python 3.11

Step 1: Install ComfyUI

git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Pitfall 1: PyTorch MPS Error

The following appears on first launch:

RuntimeError: MPS backend out of memory

Cause: MPS memory management is less mature than CUDA, so large models are prone to OOM.

Solution: Add --lowvram to the startup command:

python main.py --lowvram

Or limit the MPS cache:

export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.5

Pitfall 2: Model Paths

ComfyUI reads from models/ by default. When placing models, pay attention to the subdirectory structure:

ComfyUI/
└── models/
    ├── checkpoints/     # SD base model (.safetensors)
    ├── vae/             # VAE model
    ├── clip/            # CLIP model
    ├── loras/           # LoRA weights
    └── controlnet/      # ControlNet model

Pitfall 3: Slow HuggingFace Downloads

Use huggingface-cli with a mirror to speed things up:

pip install huggingface_hub
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download stabilityai/stable-diffusion-xl-base-1.0 --local-dir models/checkpoints/

Final Configuration

My startup script start.sh:

#!/bin/bash
source venv/bin/activate
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.3
python main.py --lowvram --listen 0.0.0.0 --port 8188

Performance Data

ModelResolutionTimeMemory
SD 1.5512×512~15s~6GB
SDXL1024×1024~45s~14GB
SDXL + LoRA1024×1024~50s~16GB

Real-World Use Cases

Scenario 1: E-commerce Product Image Generation You need to generate product images with different backgrounds for 100 SKUs. Configure a ComfyUI workflow: input a product image on a white background → ControlNet extracts the outline → prompt describes the scene ("product on a marble desk, soft lighting, studio quality") → batch generation. One SDXL image takes about 45 seconds, and 100 images take about 75 minutes, saving substantial costs compared with using cloud services.

Scenario 2: UI Design Inspiration Board Designers need to quickly generate mockups in different styles. Using ComfyUI + LoRA models (such as midjourney-style), they can enter a short prompt to get high-quality reference images. Compared with manual search, efficiency improves by more than 10 times.

Advanced Optimization: Using ComfyUI-Manager to Manage Plugins

# Install ComfyUI-Manager
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git
pip install -r ComfyUI-Manager/requirements.txt

# Restart ComfyUI, then install commonly used nodes with one click in Manager:
# - ControlNet preprocessor
# - IPAdapter (style transfer)
# - WAS Node Suite (image processing toolkit)
# - ComfyUI-Impact-Pack (automatic detection)

Performance Tuning: Custom Startup Parameters

#!/bin/bash
# start-optimized.sh
source venv/bin/activate
# MPS Memory Control
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.3
# Reduce Memory Usage with fp16
export PYTORCH_ENABLE_MPS_FALLBACK=1
python main.py \
  --lowvram \
  --fp16-vae \
  --force-fp16 \
  --listen 0.0.0.0 \
  --port 8188 \
  --front-end-version Comfy-Org/ComfyUI_frontend@latest

Conclusion

Running ComfyUI on a Mac M2 is feasible, but it requires reasonable memory management. Running a 7B LLM and SD at the same time will exhaust RAM, so using them separately is recommended. The MPS ecosystem is still improving, but it is already sufficient for daily use.

Recommended Reading