From 0e3c42a830ef87941983a6a494e8df0f90e616d2 Mon Sep 17 00:00:00 2001 From: Adrian Corduneanu Date: Wed, 26 Feb 2025 02:56:57 -0800 Subject: [PATCH] Update text2video.py to reduce GPU memory by emptying cache (#44) * Update text2video.py to reduce GPU memory by emptying cache If offload_model is set, empty_cache() must be called after the model is moved to CPU to actually free the GPU. I verified on a RTX 4090 that without calling empty_cache the model remains in memory and the subsequent vae decoding never finishes. * Update text2video.py only one empty_cache needed before vae decode --- wan/text2video.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wan/text2video.py b/wan/text2video.py index 96cfa78..2400545 100644 --- a/wan/text2video.py +++ b/wan/text2video.py @@ -252,6 +252,7 @@ class WanT2V: x0 = latents if offload_model: self.model.cpu() + torch.cuda.empty_cache() if self.rank == 0: videos = self.vae.decode(x0)