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()