From 9d3d4d784f506aa7e243184aa7d3f8e39e806414 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Sulaymonov Date: Wed, 26 Feb 2025 22:18:18 +0500 Subject: [PATCH] Check for cuda is available for macos --- wan/text2video.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wan/text2video.py b/wan/text2video.py index 96cfa78..aeaa9d4 100644 --- a/wan/text2video.py +++ b/wan/text2video.py @@ -57,7 +57,7 @@ class WanT2V: t5_cpu (`bool`, *optional*, defaults to False): Whether to place T5 model on CPU. Only works without t5_fsdp. """ - self.device = torch.device(f"cuda:{device_id}") + self.device = torch.device("mps" if torch.backends.mps.is_available() else "cpu") self.config = config self.rank = rank self.t5_cpu = t5_cpu @@ -259,7 +259,8 @@ class WanT2V: del sample_scheduler if offload_model: gc.collect() - torch.cuda.synchronize() + if torch.cuda.is_available(): + torch.cuda.synchronize() if dist.is_initialized(): dist.barrier()