Running a 5090 and getting OOM errors on 720p resolution
I tried export PYTORCH_ALLOC_CONF=expandable_segments:True to see if that would resolve the OOM errors on my 5090 but it does not. I've been at this for hours and havent been able to determine the right combination to use and not get OOM
I am also utilizing the "--quant_linear" argument
export PYTHONPATH=turbodiffusion
export PYTORCH_ALLOC_CONF=expandable_segments:True
export TOKENIZERS_PARALLELISM=false
python turbodiffusion/inference/wan2.1_t2v_infer.py \
--model Wan2.1-14B \
--dit_path checkpoints/TurboWan2.1-T2V-14B-720P-quant.pth \
--prompt "A photo realistic stylish woman walks down a Tokyo street filled with warm glowing neon and animated city signage. She wears a black leather jacket, a long red dress, and black boots, and carries a black purse. She wears sunglasses and red lipstick. She walks confidently and casually. The street is damp and reflective, creating a mirror effect of the colorful lights. Many pedestrians walk about." \
--resolution 720p \
--aspect_ratio 16:9 \
--num_steps 4 \
--seed 297308 \
--attention_type sagesla \
--sla_topk 0.15 \
--num_samples 1 \
--num_frames 77 \
--sigma_max 80 \
--save_path /home/wedwards/Documents/turbo_diffusion_ouput/t2v_20251226_104112.mp4 \
--quant_linear
Console Information . . .
[12-26 10:48:47|INFO|turbodiffusion/inference/wan2.1_t2v_infer.py:61:
im in same boat - https://github.com/thu-ml/TurboDiffusion/pull/53 i create this after some troubleshooting - this installs it properly (though targeting cuda13 + nightly pytorch) - im yet to confirm it works.
I got it working i2v - check install.sh - have to get spargeattn with blackwell support.
Try to use torch==2.8.0
2.8 doesnt work with cuda 13. i have it working with cuda 13 + pytorch nightly the problem with above is 81 frames - take it down to 49 frames.
see #42
im in same boat - #53 i create this after some troubleshooting - this installs it properly (though targeting cuda13 + nightly pytorch) - im yet to confirm it works.
I got it working i2v - check install.sh - have to get spargeattn with blackwell support.
@johndpope...These may help https://github.com/thu-ml/TurboDiffusion/issues/54#issue-3764296343 https://github.com/thu-ml/TurboDiffusion/issues/55#issue-3764302076
I'm hoping to understand your pull request so I can try out your program alongside of my own https://github.com/thu-ml/TurboDiffusion/issues/56#issue-3764350016
@johndpope, I dont know how the development team got this to work on a 5090 at 720p. Ive tried multiple strategies, memory dumping between stages, tiling (attempted), taking it down to 32 frames and I also used your technique for caching the prompts.
I'm tracking every point along the way and at one point, I'm just 800MB short of being able to fit this onto gpu before I get OOM.
The only way that I've been able to make this work at 720p is to offload to cpu, (which takes forever) but that completely defeated the purpose as it made the entire process 21 minutes to generate 5 seconds of video.
@johndpope, I dont know how the development team got this to work on a 5090 at 720p. Ive tried multiple strategies, memory dumping between stages, tiling (attempted), taking it down to 32 frames and I also used your technique for caching the prompts.
I'm tracking every point along the way and at one point, I'm just 800MB short of being able to fit this onto gpu before I get OOM.
The only way that I've been able to make this work at 720p is to offload to cpu, (which takes forever) but that completely defeated the purpose as it made the entire process 21 minutes to generate 5 seconds of video.
During our tests, we ran into the same OOM issue with Torch 2.9. Using torch==2.8.0 fixed it, which is why the README recommends that version.
Jury is still out - I’m overseas and my 5090 workstation froze up - need to reboot it but can’t ) I was in the process of trawling though hundreds of pngs to 4mb t5 embeddings then I introduce a second stage to dit embeddings (not sure how big these are - but high and low each are 14gb ) - leaving final stage to vae inflation which it calculated at 18gb - it’s in the PR with dit flag - this wouldn’t make sense for a single video with unloading - was looking forward to it all working but bricked my machine. (I don’t recommend cloudflare tunnel - better off with tailscale)
@whx1003,
During our tests, we ran into the same OOM issue with Torch 2.9. Using
torch==2.8.0fixed it, which is why the README recommends that version.
I got everything working using torch 2.9.1. I tried very hard to make torch 2.8.0 to work but it took me days to get my Linux Ubuntu environment working for TurboDiffusion. When I installed torch 2.8.0, I had to revert to older versions of torchvision, Triton and others. This made the program break so I stuck with torch 2.9.1.
@johndpope, I used your method and file "cache_t5.py" for caching the prompt to lighten the VRAM load. After a ton of attempts, I am able to get this to run using 720p but I had to make a lot of changes to make that happen. I've been able to squeeze it into 32G of VRAM, not crash but that came with a lot of monitoring memory, logging and reworking with the help of Gemini. I started with a baseline of 77 frames at 21 minutes with cpu offloading (very painful), then got it down to 16 then 13 minutes. I implemented tiling and got it down to 103 seconds but it has a subtle artifact that I notice which comes from stitching together the tiles. I've stress tested the program, taking it up to 117 frames in 134 seconds. I truly do not know if that is fast or not, as I do not have a comparison of how fast this can go if it all fit into VRAM.
I'm actually tempted to establish a script with a seed and keep iterating, so that I know everything is the same, then increasing the number of frames until I'm forced to tile to prevent OOM. Then I will know how many frames (based on that image, considering its dimensions) I can generate without running to my tiling fallback.
I'll make the program available, which includes the upgraded gradio version, modified "wan2.2_i2v_infer.py" once I'm convinced its mostly bulletproof. Again, it does depend on your method for caching the prompt.
In terms of 720p, I've spent all of my time on I2V and have not begun testing T2V
I greatly appreciate all the support from you. Hopefully, I've given some of it back
@johndpope, using your cache_t5.py as a foundation for a workflow, I have made optimizations, resulting in a pull request https://github.com/thu-ml/TurboDiffusion/pull/73
It take a lot more effort to run OOM and it runs faster.
WSL2 OOM / Freeze Fix (what I had → what broke → what I changed → results)
I’m running TurboDiffusion on WSL2 and kept hitting OOM / instability when executing multiple jobs back-to-back. My WSL2 memory setup is:
File: C:\Users\Admin\.wslconfig
[wsl2]
memory=50GB
swap=32GB
swapfile=Z:\\wsl\\swap.vhdx
Runtime environment (example):
- WSL2 Linux
6.6.87.2 - Python
3.12.3 - PyTorch
2.8.0+cu128, CUDA12.8(CUDA available) flash_attn 2.8.3,spas_sage_attn 0.1.0- RAM ~
49 GiB, swap32 GiB, VRAM ~31.84 GiB(1 GPU)
What I tried first (not enough)
Initially I only did the “standard” cleanup after each job:
gc.collect()torch.cuda.empty_cache()(and related CUDA cache cleanup)
This helped VRAM drop, but system RAM kept growing over time. After 2 consecutive jobs, I could reproduce errors, and sometimes WSL2 would crash/die completely. The key point: VRAM cleanup ≠ RAM cleanup. Even if CUDA cache is cleared, CPU heap memory can stay bloated and keep pushing WSL toward swap pressure and failure.
What actually fixed it
I added a second layer of cleanup: explicitly releasing system RAM after every job, not just CUDA/torch cleanup. I also made a few stability-oriented choices:
- Enable
malloc_trim(return freed heap memory back to the OS after each job) - Preload two I2V models (high/low) on CPU at startup (reduce runtime I/O spikes)
- Do not preload the T5 encoder; load it per job (this reduced long-run hangs/OOM for my setup)
Results after the fix (stable behavior)
After adding RAM cleanup per job, things became much more stable:
- Swap stayed low around ~2.5 / 32 GiB, and even decreased to ~2.3 GiB near the end (instead of growing toward full swap like before).
- RAM stayed ~23–30 GiB while running, then dropped back after cleanup (no longer creeping close to 49 GiB).
- VRAM behaved as expected: it increases during sampling, then drops back to a small baseline (about ~0.6 GiB reserved).
Log proof (what the cleanup shows)
Below is a concrete example where CUDA cleanup successfully reduces VRAM reserved, but RAM only drops after full cleanup:
[SYS] after_sampling: cpu=5.3% ram=33.81/49.01 GiB
[VRAM] after_sampling: allocated=0.31 GiB reserved=0.51 GiB
[MONITOR] cpu=5.4% ram=33.82/49.01 GiB swap=2.93/32.00 GiB ... vram_alloc=2.35 vram_resv=5.30
...
Cleanup: GC and CUDA cache cleanup.
[SYS] before_gc: cpu=11.5% ram=34.18/49.01 GiB
[VRAM] before_gc: allocated=0.43 GiB reserved=6.01 GiB
[SYS] after_gc: cpu=5.1% ram=34.18/49.01 GiB
[VRAM] after_gc: allocated=0.43 GiB reserved=6.01 GiB
[SYS] after_cuda_empty_cache: cpu=0.6% ram=34.18/49.01 GiB
[VRAM] after_cuda_empty_cache: allocated=0.43 GiB reserved=0.69 GiB
[MONITOR] cpu=5.1% ram=31.67/49.01 GiB swap=2.93/32.00 GiB ... vram_alloc=0.01 vram_resv=0.69
Takeaway: if you’re running repeated inference jobs on WSL2, clearing CUDA cache alone may look “successful” (VRAM drops) but still fails in the next job because RAM keeps accumulating. The practical fix is to clean both VRAM and RAM after each job, and monitor ram/swap/vram deltas (especially after after_gc and after_cuda_empty_cache) to confirm memory actually comes down.
