Skip to content

Operator task guide

How to fix Wan 2.1 and Flux diffusion VRAM limits and CUDA OOMs

Video and image diffusion pipelines (such as Wan 2.1 14B / 1.3B and Flux) hit CUDA OOM in three distinct places: loading the FP16/BF16 T5-XXL text encoder alongside the DiT backbone (~20 to 30+ GB combined), denoising high frame counts or resolutions without attention slicing, and decoding full latent frames inside the 3D/2D VAE.

Check which pipeline stage triggered the OOM first. Offloading or quantizing the T5 text encoder (FP8/GGUF), enabling sequential CPU offload or VAE tiling, and matching resolution/frame count to 8 GB, 16 GB, 24 GB, or 48 GB+ GPUs prevents crashes without degrading output quality.

Reviewed . Reference guidance is not a diagnosis of your workload.

Step-by-step method

  1. 1

    Identify which diffusion stage triggered CUDA out of memory

    Read the traceback to determine whether OOM occurred during text encoding (T5/CLIP), DiT denoising steps, or final VAE decode (very common in Wan 2.1 video generation).

    grep -n -iE 'OutOfMemoryError|vae|t5|transformer|forward' run.log
    nvidia-smi
  2. 2

    Set PYTORCH_CUDA_ALLOC_CONF and enable VAE tiling/slicing

    Fragmentation spikes sharply between text encoding, denoising, and VAE decoding. Enable expandable segments plus VAE tiling/slicing so latent decoding does not allocate gigabytes at once.

    export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
  3. 3

    Quantize or offload the DiT backbone and T5 encoder for 8 GB to 24 GB GPUs

    On 8 GB to 16 GB cards, run quantized FP8/INT8/GGUF weights (or Wan 2.1 1.3B instead of 14B) with CPU text-encoder offloading. On 24 GB cards (RTX 4090), FP8 DiT + VAE tiling runs 480p/720p video comfortably.

  4. 4

    Validate peak VRAM across full generation including VAE decode

    Log torch.cuda.max_memory_allocated() after the final video/image frame saves so you know true end-to-end peak VRAM before batching multiple requests.

Diffusion VRAM bottleneck to fix

Signals, meanings and actions for how to fix wan 2.1 and flux diffusion vram limits and cuda ooms.
SignalWhat it meansNext action
OOM immediately during prompt encodingT5-XXL + DiT weights both loaded onto GPU at BF16.Offload text encoder to CPU after encoding or use FP8/INT8 T5.
Denoising finishes 100%, then crashes with OOM at end3D/2D VAE decode peak exceeded remaining VRAM.Enable VAE tiling (enable_vae_tiling) and VAE slicing.
OOM during first denoising step on 8 GB to 12 GB GPU14B model or high frame count/resolution exceeds card VRAM.Use Wan 2.1 1.3B or FP8/GGUF quantized weights and enable model CPU offload.
Reserved minus allocated is large in OOM lineAllocator fragmentation across resolution changes.Set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True.

Evidence checklist

  • Exact pipeline model (Wan 2.1 1.3B vs 14B, Flux.1 / Flux.2) and precision
  • Resolution, frame count, and batch size
  • Traceback stage (text encoder, DiT step, or VAE decode)
  • GPU VRAM capacity (8 GB, 16 GB, 24 GB, 48 GB, 80 GB) and host RAM
  • torch.cuda.max_memory_allocated() across stages

Common mistakes

Sizing VRAM from DiT parameter count alone

T5-XXL (~9.5 GB BF16) plus 3D video VAE activations and attention intermediates easily double total memory needs.

Testing only 1 frame before deploying 81-frame video endpoints

Temporal attention and 3D VAE memory scale with frame count.

Leaving full BF16 weights on GPU during VAE decode when VRAM is tight

Offloading DiT before VAE decode frees 10 to 28 GB immediately.

Frequently asked questions

How much VRAM does Wan 2.1 require?

Wan 2.1 1.3B can run on 8 GB to 12 GB GPUs with offloading and FP8/BF16 tuning (480p), while Wan 2.1 14B at full BF16 plus T5-XXL needs 48 GB to 80 GB GPUs unless FP8 quantization and CPU offloading are enabled for 24 GB cards.

Why does Flux or Wan 2.1 crash with CUDA out of memory at 100% progress?

At step 100%, the pipeline moves from denoising latents to decoding pixels inside the VAE, which creates a sharp temporary activation peak. Enable VAE tiling and offload the DiT before decoding.

How do I run Wan 2.1 on an 8 GB VRAM GPU?

Use the 1.3B checkpoint, quantized weights (FP8/GGUF), CPU offloading for T5-XXL, VAE tiling, and 480p resolution with modest frame counts.

Does PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True help diffusion pipelines?

Yes. Diffusion workloads change tensor sizes between text encoding, DiT blocks, and VAE decoding, so expandable segments reduce fragmentation OOMs significantly.

Live diagnosis, no signup

Upload your GPU log. Find what happened first.

Get the likely cause, supporting evidence, and next safe steps with the same cloud reasoning used by paid plans. A crash the engine recognizes is answered in seconds, then checked by an independent AI review that updates this page when it finishes. A crash it does not recognize waits for the AI's own answer, which can take a few minutes. No account, card, or installation. Logs are masked at Denpex API ingress and are not saved to account history.

Before uploading, review cloud data handling and local options.

training_logs.txt
No log to hand? Try one:

Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.

3 free cloud diagnoses per day

Try Denpex for 30 days. FREE.

No credit card. No automatic subscription. See whether Denpex helps with an incident you already understand.

Start your free 30-day Team evaluation

Up to 50 diagnoses a day for 30 days. Verify your work email to activate an eligible company evaluation, then replay a resolved incident and compare the evidence and next steps with your team's confirmed cause.

Use your company email, for example alex@yourcompany.com.

Who qualifies?

Company email domains activate the free 30-day Team evaluation (up to 50 diagnoses a day) after an email and domain check, whatever mail provider you use. If we cannot verify your domain automatically, support reviews it: write to support@denpex.com. Free local diagnosis in the editor extension needs no account.

Using a personal email (Gmail, Outlook, Naver, QQ) or solo cluster? Create a free $0 account (no work email required) to save 7-day history and unlock AI fallback, or send a cluster crash log for a live walkthrough.

Apply the method to your incident

Use the three free diagnoses to review your error and relevant evidence. Keep reference guidance separate from the cause and recovery status of your own workload.

Diagnose your incident