ComfyUI's node-based workflow system is powerful — but it can also be a memory monster.
A single complex workflow with SDXL, ControlNet, upscaling, and IP-Adapter can easily exceed 24GB of VRAM. Yet with the right optimization techniques, you can run surprisingly complex workflows on a 12GB — or even 8GB — GPU.
This guide covers every practical technique to reduce ComfyUI's memory footprint, from built-in settings to workflow design patterns.
Quick wins: Enable attention optimization + tiled VAE + model offloading = save 4-8GB VRAM with minimal speed impact.
How ComfyUI Uses Memory
Before optimizing, you need to understand where memory goes.
VRAM Breakdown for a Typical SDXL Workflow
| Component | VRAM Usage | Notes |
|---|---|---|
| SDXL checkpoint (fp16) | ~6.5GB | Always loaded during generation |
| VAE decode | ~1-3GB | Spikes during decode |
| Text encoders (CLIP) | ~1.5GB | Two encoders for SDXL |
| ControlNet model | ~2-3GB | Per ControlNet |
| IP-Adapter | ~2-3GB | Plus image encoder |
| Sampling buffer | ~1-3GB | Depends on resolution |
| LoRAs | ~0.2-0.5GB | Per LoRA |
Total for a moderate workflow: 12-16GB.
Total for a complex workflow: 20-30GB+.
VRAM vs System RAM
ComfyUI uses both:
- VRAM (GPU memory): Active model inference. Fast but limited.
- System RAM: Model caching, image buffers, node data. Slower but larger.
The key insight: ComfyUI can automatically swap models between VRAM and RAM. This is the foundation of most memory optimization — though this swapping is a form of VRAM spilling that comes with a significant, non-linear performance penalty.
Related: Understanding SDXL VRAM requirements helps you plan which optimizations to apply.
Built-in Memory Settings
ComfyUI has several built-in flags that dramatically change memory behavior. Start here.
Launch Arguments
Add these to your ComfyUI launch command:
# Moderate VRAM saving (recommended for 8-12GB GPUs)
python main.py --lowvram
# Aggressive VRAM saving (for 6-8GB GPUs)
python main.py --novram
# Force fp16 (half precision) — saves ~30% VRAM
python main.py --force-fp16
# Combine for maximum savings
python main.py --lowvram --force-fp16What Each Flag Does
| Flag | VRAM Saved | Speed Impact | Best For |
|---|---|---|---|
--lowvram | 3-6GB | -20-40% | 8-12GB GPUs |
--novram | 5-10GB | -50-70% | 6-8GB GPUs |
--force-fp16 | 2-3GB | ~0% | All GPUs |
--highvram | 0 (uses more) | +10-20% | 24GB+ GPUs |
Recommendation: If you have 12GB or less, start with --lowvram --force-fp16.
How --lowvram Works
When enabled, ComfyUI:
- Loads only the currently executing model into VRAM
- Moves other models to system RAM
- Swaps models in/out as the workflow progresses
Example: In a SDXL + ControlNet + upscaling workflow:
- Step 1: Load SDXL → generate image → unload SDXL
- Step 2: Load ControlNet → process → unload ControlNet
- Step 3: Load upscaler → upscale → unload
Instead of needing 16GB+ simultaneously, you only need enough for the largest single model (~6.5GB for SDXL).
Troubleshooting: Still getting "CUDA out of memory"? See our complete fix guide.
Attention Optimization
This is the single highest-impact optimization with zero quality loss.
Enable xformers or SDP Attention
ComfyUI automatically selects the best attention backend, but you can force it:
# Use PyTorch SDP attention (recommended, built into PyTorch 2.0+)
python main.py --use-pytorch-cross-attention
# Or install and use xformers
pip install xformers
# ComfyUI auto-detects xformers when installedImpact
| Attention Mode | VRAM Usage | Speed |
|---|---|---|
| Default (naive) | Baseline | Baseline |
| SDP attention | -20-30% | +5-15% faster |
| xformers | -20-30% | +10-20% faster |
Why it works: Standard attention computes the full N×N attention matrix. Optimized attention computes it in blocks, never materializing the full matrix.
Example savings at 1024×1024:
- Default: ~3GB for attention computation
- SDP/xformers: ~1.5GB
No trade-off: Quality is mathematically identical. There's no reason not to enable this.
Tiled VAE Decoding
VAE decode is a hidden memory killer — it can spike VRAM by 2-4GB during the final decode step.
The Problem
The VAE converts latent space images back to pixel space. For high resolutions, this requires huge tensors:
| Resolution | VAE VRAM Spike |
|---|---|
| 512×512 | ~0.5GB |
| 1024×1024 | ~2GB |
| 2048×2048 | ~8GB |
| 4096×4096 | ~32GB |
Even if your model fits in VRAM, the VAE decode step can cause an OOM crash.
The Solution: Tiled VAE
Instead of decoding the entire image at once, tiled VAE processes it in small tiles:
In ComfyUI:
- Replace the standard
VAE Decodenode withVAE Decode (Tiled) - Set tile size: 512×512 for low VRAM, 1024×1024 for comfortable
Or use the Tiled VAE node from ComfyUI-Manager:
Node: VAE Decode Tiled
├── Tile size: 512 (lower = less VRAM, slower)
├── Overlap: 64 (prevents tile seam artifacts)
└── Fast mode: true (recommended)Impact
| Method | VRAM for 2048×2048 | Speed |
|---|---|---|
| Standard VAE | ~8GB | Fast |
| Tiled VAE (512) | ~1GB | -30% |
| Tiled VAE (1024) | ~2.5GB | -10% |
When to use: Always use tiled VAE if generating above 1024×1024, or if you're on 8-12GB GPUs.
Model Offloading Strategies
ComfyUI's built-in model management is good, but you can do better with explicit strategies.
Sequential Model Loading
The biggest memory waste is loading multiple models simultaneously. Design your workflow to use models sequentially, not in parallel.
Bad workflow (high VRAM):
SDXL Checkpoint ──┐
ControlNet ───────┤──→ KSampler ──→ VAE Decode
IP-Adapter ───────┘All three models loaded in VRAM simultaneously: ~14GB.
Good workflow (low VRAM):
SDXL + ControlNet ──→ KSampler ──→ (unload)
│
Upscaler ──→ Upscale ──→ VAE Decode ←┘Models load/unload as needed: peak ~8GB.
Explicit Model Unloading
Use ComfyUI's Unload Model or Free Memory nodes:
KSampler ──→ Free Memory ──→ Upscaler ──→ UpscaleThis forces ComfyUI to release VRAM before loading the next model.
Use ComfyUI-Manager's Memory Tools
Install ComfyUI-Manager for additional memory management:
- Unload All Models — Clear everything from VRAM
- Free Memory — Force garbage collection
- Model Manager — See which models are loaded
FP8 and Quantized Models
Using lower precision reduces model size in VRAM with minimal quality impact.
Precision Comparison
| Precision | SDXL Model Size | Quality | Support |
|---|---|---|---|
| fp32 | ~13GB | Perfect | Universal |
| fp16 | ~6.5GB | Near-perfect | Default |
| fp8 (e4m3fn) | ~3.3GB | Very good | SDXL/Flux |
| NF4 (4-bit) | ~1.8GB | Good | Flux mainly |
How to Use FP8 in ComfyUI
ComfyUI natively supports fp8 checkpoints:
- Download fp8 checkpoints — Many model hosts provide fp8 versions
- Or convert manually:
# In ComfyUI, use the "Checkpoint Loader (Simple)" node
# Set: weight_dtype = fp8_e4m3fn- Use the UNETLoader node with fp8 option for manual control
GGUF Models in ComfyUI
For even more aggressive quantization, use GGUF format with ComfyUI-GGUF:
GGUF Loader ──→ (Q4/Q5/Q8 model) ──→ KSampler| GGUF Quantization | VRAM | Quality vs fp16 |
|---|---|---|
| Q8_0 | ~4GB | 99%+ |
| Q5_1 | ~3GB | 97%+ |
| Q4_K_M | ~2.5GB | 95%+ |
Best balance: Q5_1 or Q8_0 — significant VRAM savings with nearly imperceptible quality loss.
Related: Learn more about choosing the right GPU for AI, including how quantization affects hardware requirements.
Workflow Design Patterns
How you build your workflow matters as much as any setting.
Pattern 1: Two-Pass Generation
Instead of one complex workflow, split into two passes:
Pass 1 — Low resolution:
- Generate at 512×512 or 768×768
- Use ControlNet, IP-Adapter, LoRAs
- Fast iteration, low VRAM
Pass 2 — Upscale:
- Take the best result
- Upscale to 2048×2048 or higher
- Use dedicated upscaler node
This approach peaks at ~8GB instead of ~16GB.
Pattern 2: ControlNet Preprocessing Separation
Preprocess ControlNet inputs before the main generation:
Step 1: Image ──→ Canny/Depth ──→ Save preprocessed
Step 2: Load preprocessed ──→ ControlNet ──→ KSamplerAvoids loading the preprocessor and the generation model simultaneously.
Pattern 3: Batch Processing with Queue
Instead of batch_size > 1 (which multiplies VRAM), use ComfyUI's queue:
- Batch size 4 at 1024×1024: ~20GB VRAM
- Queue 4 images one by one: ~8GB VRAM
Same result, fraction of the memory. Just takes 4x longer.
Tip: On cloud GPUs with larger VRAM, you can use batch sizes for faster throughput.
Pattern 4: Resolution Ladder
For high-resolution outputs, generate in stages:
512×512 ──→ 1024×1024 ──→ 2048×2048
(txt2img) (img2img) (upscaler)Each step uses manageable VRAM. The final quality is often better than direct high-res generation too.
ControlNet Memory Optimization
ControlNet is one of the biggest VRAM consumers. Here's how to tame it.
Use ControlNet Lite / Compact Models
| ControlNet Version | VRAM Usage |
|---|---|
| Full model | 2.5-3.5GB |
| Lite/Small model | 0.8-1.2GB |
| Union model | 1.5-2GB (replaces multiple) |
ControlNet Union is particularly useful — one model handles multiple control types (canny, depth, pose, etc.), replacing 3-4 separate models.
Apply ControlNet at Lower Resolution
The ControlNet preprocessor resolution doesn't need to match your generation resolution:
Control image (512×512) ──→ ControlNet ──→ SDXL generation (1024×1024)Lower control resolution = less VRAM, usually with negligible quality impact.
Reduce ControlNet Strength Range
Using control_end_percent < 1.0 allows the ControlNet to be unloaded partway through generation:
strength: 0.8
start_percent: 0.0
end_percent: 0.5 ← ControlNet can be freed after 50% of samplingThis frees VRAM during the latter half of generation.
Monitoring VRAM Usage
You can't optimize what you can't measure.
Built-in ComfyUI Logging
Launch with verbose logging:
python main.py --verboseThis shows model loading/unloading events and memory usage.
nvidia-smi Monitoring
Run in a separate terminal:
# Real-time monitoring (updates every 1 second)
watch -n 1 nvidia-smi
# Or use the dmon flag for continuous output
nvidia-smi dmon -s u -d 1Key metrics:
- Memory Used: Current VRAM consumption
- Memory Total: Your GPU's total VRAM
- GPU Util %: Whether you're compute-bound or memory-bound
Identify the Memory Bottleneck
| Symptom | Cause | Solution |
|---|---|---|
| OOM during model load | Too many models | Sequential loading |
| OOM during sampling | Resolution too high | Lower resolution or --lowvram |
| OOM during VAE decode | Large output image | Tiled VAE |
| OOM during ControlNet | Multiple ControlNets | ControlNet Lite or Union |
| Slow but no OOM | Constant swapping | Reduce workflow complexity |
Deeper analysis: Compute-bound vs memory-bound explained with real community benchmarks.
Recommended Settings by GPU VRAM
8GB GPUs (RTX 4060, RTX 3070, RTX 2080)
python main.py --lowvram --force-fp16| Setting | Value |
|---|---|
| Attention | SDP or xformers |
| VAE | Tiled (512×512) |
| Models | fp8 or GGUF Q8 |
| Max resolution | 768×768 → upscale |
| ControlNet | Lite only, 1 max |
| Batch size | 1 |
12GB GPUs (RTX 3060, RTX 4070)
python main.py --force-fp16| Setting | Value |
|---|---|
| Attention | SDP or xformers |
| VAE | Tiled for >1024 |
| Models | fp16 (default) |
| Max resolution | 1024×1024 |
| ControlNet | 1-2 models OK |
| Batch size | 1-2 |
Real-world test: See RTX 3060 SDXL real-world limits for detailed benchmarks.
16-24GB GPUs (RTX 4080, RTX 4090, RTX 3090)
python main.py --force-fp16
# Or for maximum speed:
python main.py --highvram --force-fp16| Setting | Value |
|---|---|
| Attention | SDP or xformers |
| VAE | Standard for 1024, tiled for 2048+ |
| Models | fp16 |
| Max resolution | 2048×2048 |
| ControlNet | Multiple OK |
| Batch size | 2-4 |
40GB+ GPUs (A100, A6000 — Cloud)
python main.py --highvramEverything runs comfortably. Focus on speed rather than memory:
- Use batch sizes for throughput
- Keep all models loaded
- No need for tiled VAE or lowvram
Get started: Browse 40GB+ cloud GPUs for complex workflows.
When Optimization Isn't Enough
Even with every optimization applied, some workflows simply need more VRAM:
- SDXL + 3 ControlNets + IP-Adapter: 16GB minimum even with fp8
- AnimateDiff 32+ frames: 24GB minimum
- Flux.1 Dev full precision: 24GB minimum
- Video generation (SVD, Wan, etc.): 24-48GB
Cloud GPU: The Practical Solution
When you've hit the wall with your local GPU, cloud GPUs give you instant access to more VRAM without buying new hardware.
| Cloud GPU | VRAM | Best For | Price |
|---|---|---|---|
| RTX 4090 | 24GB | Most ComfyUI workflows | ~$0.39/hr |
| A5000 | 24GB | Professional work | ~$0.43/hr |
| A100 40GB | 40GB | Complex + video | ~$0.63/hr |
Cost example: Running a complex video workflow for 4 hours on A100 = $2.52. That's a fraction of buying a 24GB GPU.
Calculate your costs: Use our GPU cost calculator to plan your budget.
Hybrid Workflow Strategy
Many power users combine local and cloud:
- Local 12GB GPU — Design workflow, iterate on prompts, test settings
- Cloud 24-40GB GPU — Final high-quality renders, video, batch jobs
This gives you fast local iteration with cloud power when you need it.
Compare options: GPU market | GPU comparison tool | Cost calculator
Quick Reference Cheat Sheet
Top 5 Optimizations (Do These First)
| # | Optimization | VRAM Saved | Effort |
|---|---|---|---|
| 1 | Enable SDP/xformers attention | 1-2GB | 1 min |
| 2 | Use --force-fp16 | 2-3GB | 1 min |
| 3 | Tiled VAE for >1024px | 2-6GB | 2 min |
| 4 | Use fp8 or GGUF models | 2-4GB | 5 min |
| 5 | Sequential model loading | 3-8GB | 10 min |
Common Issues Quick Fix
| Problem | Quick Fix |
|---|---|
| OOM on startup | Add --lowvram flag |
| OOM during generation | Reduce resolution, enable tiled VAE |
| OOM with ControlNet | Switch to Lite model |
| Slow generation | Remove --novram, use --lowvram instead |
| Black images | Disable fp8, use fp16 |
| Tile seams in output | Increase tiled VAE overlap to 128 |
Conclusion
ComfyUI memory optimization isn't about one magic setting — it's about combining multiple techniques:
- Start with built-in flags —
--lowvram --force-fp16 - Enable attention optimization — Free 1-2GB instantly
- Use tiled VAE — Prevent decode OOM crashes
- Design sequential workflows — Avoid loading everything at once
- Consider quantized models — fp8 or GGUF for further savings
With these techniques, a 12GB GPU can handle workflows that would otherwise require 24GB+. And when you truly need more, cloud GPUs provide instant access to 40GB+ at a fraction of hardware cost.
The best optimization strategy is matching your tools to your task. Don't fight your hardware — optimize your workflow.
Further Reading
- SDXL VRAM Requirements Guide — How much VRAM each workflow needs
- CUDA Out of Memory Fix — Troubleshoot OOM errors
- RTX 3060 SDXL Real-World Test — 12GB GPU limits in practice
- Best 12GB VRAM GPU — Budget GPU recommendations
- RTX 4090 vs A100 vs H100 — Professional GPU comparison
- Cloud GPU Pricing — Compare cloud GPU costs
- GPU Cost Calculator — Estimate your cloud GPU expenses
- Browse GPU Market — Find available cloud GPUs now
Last updated: February 2026
