ComfyUI Crashing on Mac with Big Images? Here's the Fix

If you're using ComfyUI on a Mac to create awesome AI images, you might have hit a wall when trying to make them really big. Specifically, if you try to generate an image larger than 1920x1920 pixels, you've probably seen your process crash right at the end with a weird error message.

It's a frustrating problem, but don't worry, there's a simple fix!

The Problem: A "failed assertion" Error

When ComfyUI is almost done generating your large image, it suddenly stops and you see an error message in your terminal that looks something like this:

log
|
/AppleInternal/Library/BuildRoots/.../MPSNDArray.mm:829: failed assertion \`... Error: NDArray dimension length \> INT\_MAX'

In simple terms, this is a bug in a recent version of PyTorch, the library ComfyUI uses for its AI magic on Apple Silicon (M1, M2, M3 chips). The part of PyTorch that handles image data on the Mac's graphics chip (Metal Performance Shaders or MPS) can't handle the dimensions of your super-sized image.

The Solution: Downgrade Your PyTorch Version

The good news is you can fix this by going back to a slightly older, more stable version of PyTorch. The key is to install version 2.4.0.

Here's how to do it:

bash
|
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0

This command tells Python's package manager, pip, to uninstall your current PyTorch and install the specific versions that are known to work without this bug.

After the installation is complete, restart ComfyUI, and you should now be able to generate those huge images without any crashes. 🎉

Tested and Confirmed

I've personally tested this fix on an M1 Max with 64GB of RAM, successfully generating 3000x3000 pixel images without any crashes. Before the PyTorch downgrade, ComfyUI would consistently crash when attempting to generate images at this resolution. After installing PyTorch 2.4.0, the same workflows completed successfully.

Need a Different Version?

This bug is related to specific versions of PyTorch. If you need to find other previous versions for any reason, the official PyTorch website has a helpful archive.

For those interested in the technical details, you can follow the bug reports on GitHub:

Happy generating!