From d3eaae7f54b84c28b426fcf20651223f16eaf17b Mon Sep 17 00:00:00 2001 From: BVH <82035780+bvhari@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:25:20 +0530 Subject: [PATCH] Better fix for the Transformer warning Explicitly set the value of patch_model_to to the intended torch device obtained from get_torch_device. This fixes the Transformer warning. Currently, it takes the current device of the model, which is cpu as the model is loaded in to cpu by deault. --- comfy/model_management.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/comfy/model_management.py b/comfy/model_management.py index a98d11807..3e17c77c4 100644 --- a/comfy/model_management.py +++ b/comfy/model_management.py @@ -286,7 +286,7 @@ class LoadedModel: return self.model_memory() def model_load(self, lowvram_model_memory=0): - patch_model_to = self.device + patch_model_to = get_torch_device() self.model.model_patches_to(self.device) self.model.model_patches_to(self.model.model_dtype()) @@ -304,7 +304,7 @@ class LoadedModel: raise e if is_intel_xpu() and not args.disable_ipex_optimize: - self.real_model = torch.xpu.optimize(self.real_model.to("xpu").eval(), inplace=True, auto_kernel_selection=True, graph_mode=True) + self.real_model = torch.xpu.optimize(self.real_model.eval(), inplace=True, auto_kernel_selection=True, graph_mode=True) self.weights_loaded = True return self.real_model