Generate stunning AI videos locally without cloud GPUs!
📖 Documentation • 🚀 Quick Start • 🎥 Examples • ⚙️ Performance
Successfully runs CogVideoX-5B (10GB model) for text-to-video generation on Mac M4 Pro with 64GB RAM using Apple's Metal Performance Shaders (MPS).
- ✅ Fixed MPS autocast incompatibility - The main blocker for Mac users
- ✅ Resolved node registration errors - Custom patches for ComfyUI
- ✅ Found optimal memory limits - 30 frames max for stable generation
- ✅ 4-second videos in ~18 minutes - No cloud GPUs needed
- ✅ 99% GPU utilization - Full Apple Silicon power
|
30 frames, 30 steps, 18 min waterfall_success.mp4 |
25 frames, 20 steps, 12 min example_1.mp4 |
|
25 frames, 20 steps, 12 min example_2.mp4 |
25 frames, 20 steps, 12 min example_3.mp4 |
| Component | Spec |
|---|---|
| Model | Mac Mini M4 Pro |
| CPU | 14-core (10P + 4E) |
| GPU | 20-core |
| RAM | 64GB Unified Memory |
| Storage | 2TB+ recommended |
| OS | macOS 26.1+ |
- RAM: 64GB (critical - 32GB insufficient)
- Storage: 50GB free (models + workspace)
- Chip: M4 Pro or better
| Frames | Seconds | Steps | Resolution | Time | Success Rate |
|---|---|---|---|---|---|
| 25 | 3s | 20 | 512x384 | 12 min | ✅ 100% |
| 30 | 4s | 30 | 512x384 | 18 min | ✅ 100% |
| 49 | 6s | 30 | 512x384 | 40 min | |
| 49 | 6s | 50 | 512x384 | 70 min | ❌ Corrupts |
| >30 | >4s | Any | Any | - | ❌ White screen |
During generation: 99% GPU usage
Memory bandwidth: 273 GB/s fully utilized
Power draw: ~50W sustained
Thermals: Cool (< 60°C)
cd ~/Desktop
git clone https://github.com/comfyanonymous/ComfyUI
cd ComfyUI
python -m venv ../venv
source ../venv/bin/activate
pip install torch torchvision torchaudio
pip install -r requirements.txtcd custom_nodes
git clone https://github.com/kijai/ComfyUI-CogVideoXWrapper
cd ComfyUI-CogVideoXWrapper
pip install -r requirements.txtCritical: The default nodes don't work on Mac. Apply our fixes:
# Backup original
cp nodes.py nodes.py.backup
# Download and apply our fixed version
curl -o nodes.py https://raw.githubusercontent.com/nicedreamzapp/CogVideoX-Mac-Setup/main/fixes/nodes_fixed.pyFind line ~755 in nodes.py and replace:
# OLD (breaks on Mac):
autocast_context = torch.autocast(
mm.get_autocast_device(device), dtype=dtype
) if any(q in model["quantization"] for q in ("e4m3fn", "GGUF")) else nullcontext()
# NEW (Mac compatible):
# MPS-safe autocast with fallback
if str(device.type) == "mps":
autocast_context = nullcontext()
else:
autocast_context = torch.autocast(
mm.get_autocast_device(device), dtype=dtype
) if any(q in model["quantization"] for q in ("e4m3fn", "GGUF")) else nullcontext()Around line ~684, verify these default values exist:
else:
# Default dimensions for text-to-video
H = 60 # 480 / 8
W = 90 # 720 / 8
B = 1
T = num_frames
C = 16
latents = None# T5 Text Encoder (9GB)
cd ../../models/clip
wget https://huggingface.co/mcmonkey/google_t5-v1_1-xxl_encoderonly/resolve/main/t5xxl_fp16.safetensors
# CogVideoX-5B will auto-download on first run (10GB)cd ~/Desktop/ComfyUI
export PYTORCH_ENABLE_MPS_FALLBACK=1
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
python main.py --force-fp16 --lowvram- Open http://127.0.0.1:8188
- Download our workflow
- Drag into ComfyUI browser
- Adjust settings (see below)
- Queue Prompt!
For Maximum Success Rate:
Empty Latent Image:
width: 512
height: 384
batch_size: 1
CogVideo Sampler:
num_frames: 30 # CRITICAL: Don't exceed!
steps: 20-30 # Higher = better quality but slower
cfg: 6.0-6.5
scheduler: CogVideoXDDIM
Load CLIP:
clip_name: t5xxl_fp16.safetensors
type: sd3- Max frames: 30 (31+ causes white screen corruption)
- Max steps: 30 (50+ exhausts memory during VAE decode)
- Resolution: 512x384 (higher resolutions untested/risky)
Symptoms: Generation completes 100% but video is white with artifacts
Causes:
- Too many frames (>30)
- Too many steps (>30)
- Memory exhaustion during VAE decode
Solutions:
- Reduce to 25-30 frames
- Use 20-30 steps maximum
- Enable VAE tiling in CogVideo Decode node
- Restart ComfyUI to clear memory
Error: Failed to allocate private MTLBuffer for size XXXGB
Solutions:
- Reduce frames to 25
- Reduce steps to 20
- Close all other applications
- Restart Mac to clear unified memory
Error: Cannot import CogVideoXWrapper module
Solutions:
- Check indentation in nodes.py (line 674 must have 8 spaces)
- Verify fixes were applied correctly
- Restore from
nodes.py.backupand reapply fixes
CogVideoX-Mac-Setup/
├── README.md
├── fixes/
│ ├── nodes_original.py # Backup of original
│ └── nodes_fixed.py # Mac-compatible version
├── workflows/
│ └── cogvideox_1_0_5b_T2V_02.json
└── examples/
├── videos/ # (hosted on GitHub)
└── screenshots/
What We Fixed:
-
MPS Autocast Bug: PyTorch's
torch.autocast()doesn't support MPS device type, causingRuntimeError. Wrapped in device check withnullcontext()fallback. -
H/W Variable Bug: Text-to-video mode didn't initialize height/width when no input image present, causing
UnboundLocalError. Added default values based on model expectations. -
Memory Limits: Through testing, discovered 30-frame hard limit on M4 Pro 64GB due to VAE decode memory requirements (~46GB buffer allocation at 49 frames).
Found this helpful? Consider:
- ⭐ Star this repo
- 🐛 Report issues you encounter
- 💡 Share your successful configurations
- 🎥 Submit example videos
- ComfyUI - The UI framework
- CogVideoX - Original model
- ComfyUI-CogVideoXWrapper - The wrapper we fixed
| Metric | Mac M4 Pro 64GB | RTX 4090 + 128GB |
|---|---|---|
| 30 frames, 30 steps | 18 minutes | ~5 minutes |
| Max video length | 4 seconds | 40+ seconds |
| Resolution | 512x384 | 1024x768+ |
| Power draw | 50W | 450W |
| Noise | Silent | Jet engine |
| Cost | $2,200 | $4,500+ |
Verdict: Mac is perfect for learning/experimenting. RTX for production.
This guide and fixes are MIT licensed. Original CogVideoX and ComfyUI have their own licenses.
- kijai for the ComfyUI-CogVideoXWrapper
- THUDM for CogVideoX model
- comfyanonymous for ComfyUI
- Apple for M4 Pro silicon that makes this possible
Made with ❤️ on Apple Silicon