The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Move code to empty gpu cache to model_management.py
comfyanonymousdeb2b93e797c
diff --git a/comfy/model_management.py b/comfy/model_management.pyindex 8303cb437..76455e4a2 100644--- a/comfy/model_management.py+++ b/comfy/model_management.py@@ -307,6 +307,15 @@ def should_use_fp16():return True+def soft_empty_cache():+ global xpu_available+ if xpu_available:+ torch.xpu.empty_cache()+ elif torch.cuda.is_available():+ if torch.version.cuda: #This seems to make things worse on ROCm so I only do it for cuda+ torch.cuda.empty_cache()+ torch.cuda.ipc_collect()+#TODO: might be cleaner to put this somewhere elseimport threadingdiff --git a/execution.py b/execution.pyindex 9d9ca5f68..73be6db03 100644--- a/execution.py+++ b/execution.py@@ -10,7 +10,7 @@ import gcimport torchimport nodes-from model_management import xpu_available+import comfy.model_managementdef get_input_data(inputs, class_def, unique_id, outputs={}, prompt={}, extra_data={}):valid_inputs = class_def.INPUT_TYPES()@@ -204,12 +204,7 @@ class PromptExecutor:self.server.send_sync("executing", { "node": None }, self.server.client_id)gc.collect()- if torch.cuda.is_available():- if torch.version.cuda: #This seems to make things worse on ROCm so I only do it for cuda- torch.cuda.empty_cache()- torch.cuda.ipc_collect()- elif xpu_available:- torch.xpu.empty_cache()+ comfy.model_management.soft_empty_cache()def validate_inputs(prompt, item):