ComfyUI Out of Memory: Fix CUDA OOM, Python MemoryError, and VRAM Spikes
Diagnose ComfyUI out-of-memory failures by separating CUDA VRAM, Python RAM, Apple MPS, and PyTorch allocator problems before changing your workflow.
If ComfyUI fails with out of memory, do not start by reinstalling packages. First identify which memory pool is actually exhausted.
ComfyUI can run out of:
- GPU VRAM (
CUDA out of memory,torch.cuda.OutOfMemoryError) - system RAM (
MemoryError,DefaultCPUAllocator: not enough memory) - Apple unified memory (
MPS backend out of memory) - allocator-friendly contiguous blocks, even when a monitor appears to show free memory
The fix is different for each case.
Quick Diagnosis
| Error text or symptom | Most likely pool | First check | First safe fix |
|---|---|---|---|
CUDA out of memory | NVIDIA VRAM | nvidia-smi while the workflow runs | Lower resolution, batch size, frame count, or use --lowvram |
MemoryError | System RAM | Task Manager memory + page file pressure | Close RAM-heavy apps, split the workflow, increase page file |
DefaultCPUAllocator: not enough memory | System RAM / CPU allocator | Watch RAM rise before the crash | Reduce parallel branches and avoid huge image/video tensors |
MPS backend out of memory | Apple unified memory | Activity Monitor memory pressure | Use smaller models/resolution or shorter video clips |
| OOM with "free" VRAM visible | PyTorch reserved/fragmented memory or another process | Compare nvidia-smi with PyTorch memory summary | Restart ComfyUI, reduce peak allocation size, reserve more headroom |
Evidence from real ComfyUI issues
This page is prioritized because memory failures are a real support pattern, not a theoretical edge case.
In the local ComfyUI GitHub Issues dataset collected on 2026-03-19, the OutOfMemoryError | out of memory cluster had 203 issues, 99 still open, and a latest seen date of 2026-03-19. The same dataset also shows related clusters for allocation would exceed allowed memory, cuda out of memory, and MPS backend out of memory.
Our local telemetry join also ranked CUDA out of memory and Python MemoryError among the strongest service opportunities. Use those signals as demand evidence, then use the checks below to choose the right fix.
Step 1: Check GPU VRAM
On Windows, open Command Prompt while ComfyUI is running:
nvidia-smiLook for:
- another AI app using VRAM
- browser or game processes using GPU memory
- ComfyUI filling nearly all VRAM before failure
- a second ComfyUI instance still running
If you have multiple NVIDIA GPUs, confirm ComfyUI is using the intended card. See ComfyUI Multi GPU before changing devices.
Step 2: Check the active Python environment
Run this in the same Python environment that launches ComfyUI:
python -c "import torch; print('cuda', torch.cuda.is_available()); print(torch.cuda.mem_get_info() if torch.cuda.is_available() else 'no cuda')"If CUDA is available, this prints free and total VRAM from PyTorch's view. For deeper inspection:
python -c "import torch; print(torch.cuda.memory_summary() if torch.cuda.is_available() else 'no cuda')"For the Windows portable package, use the embedded Python:
.\python_embeded\python.exe -s -c "import torch; print('cuda', torch.cuda.is_available()); print(torch.cuda.mem_get_info() if torch.cuda.is_available() else 'no cuda')"If CUDA is not available at all, this is not an OOM problem. Use Torch Not Compiled With CUDA Enabled first.
Step 3: Reduce the peak allocation
Most ComfyUI OOM failures happen at a peak point: model load, VAE decode, upscale, video sampling, or a custom node that creates a large tensor.
Try these in order:
- Reduce output resolution.
- Set batch size to
1. - For video, reduce frame count before reducing quality settings.
- Use a smaller checkpoint or a quantized/GGUF model when available.
- Avoid running two large branches in one workflow if they can be split into stages.
- Save intermediate images or latents, then continue in a second workflow.
If you are using Flux, Wan, HunyuanVideo, LTX, or other large modern models, the model choice itself may exceed your hardware. Check GPU Compatibility and Model Types Explained before trying random package changes.
Step 4: Use launch flags carefully
For manual installs:
python main.py --lowvramFor portable Windows, edit the .bat file and add the flag after main.py:
.\python_embeded\python.exe -s ComfyUI\main.py --lowvramIf the OS or another app needs more headroom, reserve VRAM:
python main.py --lowvram --reserve-vram 1.0Useful flags:
| Flag | When to try it | Tradeoff |
|---|---|---|
--lowvram | Limited VRAM or repeated CUDA OOM | Slower generation |
--novram | --lowvram still fails | Much slower |
--reserve-vram 1.0 | System/browser/driver needs headroom | Less VRAM available to ComfyUI |
--cpu-vae | VAE decode OOM | Slower decode, more system RAM use |
--cache-none | RAM/VRAM grows from cached node results | More recomputation |
Do not add every memory flag at once. Change one thing, restart ComfyUI, and test the same workflow.
Step 5: Distinguish VRAM from system RAM
CUDA out of memory usually means GPU VRAM. MemoryError and DefaultCPUAllocator usually mean system RAM.
For system RAM pressure:
- close browsers, video editors, games, and other AI tools
- increase the Windows page file if the machine is paging heavily
- avoid loading several large models in one workflow
- split long video workflows into shorter chunks
- avoid huge input images unless the model actually needs them
If RAM rises after installing a custom node, disable that node and retest. See Installed Custom Nodes and Broke ComfyUI.
What not to do
- Do not reinstall PyTorch just because the error says OOM.
- Do not assume
torch.cuda.empty_cache()fixes a workflow that genuinely needs more peak memory. - Do not use
--highvramon a low-VRAM machine; it keeps models resident in GPU memory. - Do not install memory-optimization custom nodes while the base workflow is still untested.
- Do not update all custom nodes during an urgent OOM repair.
When an update caused the OOM
If the same workflow worked yesterday and now OOMs after an update:
- Save the current workflow JSON.
- Confirm whether ComfyUI, the frontend, or a custom node changed.
- Test the same workflow with custom nodes disabled if possible.
- Try a smaller model/resolution only to confirm the failure type.
- Restore a backup or downgrade in a separate folder if production work is blocked.
Use ComfyUI Won't Update or Need to Downgrade before rolling back the only working environment.
How Wonderful Launcher helps
Out-of-memory failures become expensive when users lose track of which workflow, model, custom node, and ComfyUI version caused the spike.
Wonderful Launcher helps by keeping environments separate, preserving launch paths, and making it easier to inspect logs after a crash. If the machine is stuck in repeated OOM, dependency, or update failures, expert help is usually faster than trying random flags for hours.
Source references
- ComfyUI command-line arguments source
- PyTorch CUDA semantics and memory management
- PyTorch CUDA memory summary
- PyTorch empty_cache documentation
- ComfyUI issue example: OOM killer with LTX workflow
- ComfyUI issue example: CUDA OOM despite visible free memory
Related guides
- ComfyUI GPU Compatibility
- ComfyUI Multi GPU
- Torch Not Compiled With CUDA Enabled
- ComfyUI Dependency Conflicts
- ComfyUI Won't Update or Need to Downgrade
Source References
Start with Wonderful Launcher if this issue touches your real ComfyUI environment. Use the docs to understand the fix, and use the app to inspect the machine you already have.
Download Wonderful LauncherDid this fix your issue?
Your answer helps prioritize verified ComfyUI repairs.