From 92254659753b7ee6dfed9d68bbeb6fe9e743749e Mon Sep 17 00:00:00 2001 From: Simon Lui <502929+simonlui@users.noreply.github.com> Date: Sat, 19 Aug 2023 21:35:22 -0700 Subject: [PATCH] Further tuning and fix mem_free_total. --- comfy/model_management.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/comfy/model_management.py b/comfy/model_management.py index 83e2f6d..51f6314 100644 --- a/comfy/model_management.py +++ b/comfy/model_management.py @@ -271,8 +271,7 @@ class LoadedModel: self.model_accelerated = True if xpu_available and not args.disable_ipex_optimize: - self.real_model.training = False - self.real_model = torch.xpu.optimize(self.real_model, inplace=True) + self.real_model = torch.xpu.optimize(self.real_model.eval(), inplace=True, auto_kernel_selection=True, graph_mode=True) return self.real_model @@ -515,7 +514,7 @@ def get_free_memory(dev=None, torch_free_too=False): mem_allocated = stats['allocated_bytes.all.current'] mem_reserved = stats['reserved_bytes.all.current'] mem_free_torch = mem_reserved - mem_active - mem_free_total = torch.xpu.get_device_properties(dev).total_memory - mem_allocated + mem_free_torch + mem_free_total = torch.xpu.get_device_properties(dev).total_memory - mem_allocated else: stats = torch.cuda.memory_stats(dev) mem_active = stats['active_bytes.all.current']