Deploying ComfyUI on Mac M2: A Record of Pitfalls
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
| Model | Resolution | Time | Memory |
|---|---|---|---|
| SD 1.5 | 512×512 | ~15s | ~6GB |
| SDXL | 1024×1024 | ~45s | ~14GB |
| SDXL + LoRA | 1024×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
- ComfyUI Official Wiki, installation and configuration guide
- ComfyUI Examples, various workflow examples
- ComfyUI-Manager, one-click plugin management
- OpenArt Workflow Library, community-shared ComfyUI workflows
More in Playbooks
- MemoryHub v2.0 Full Record of Ten-Database Sync: The 6-Hour Battle from 0 Points to 3,892 Records
- agentmemory Full Feature Deployment Log: From GitHub Trending to Four Platform Automatic Memory Capture
- Complete Guide to 14 Financial Services AI Skills: From Deal Sourcing and M&A Models to Catalyst Calendars
- Ten-Day Pitfall Log: 16 Fatal Lessons in Building an AI Assistant System