Add a node that runs torch / python gc

This commit is contained in:
asagi4
2024-02-08 17:46:25 +02:00
parent a7728ebb15
commit 49479cdaa6
+23
View File
@@ -0,0 +1,23 @@
import gc
import comfy.model_management
import logging
log = logging.getLogger("comfyui-misc-utils")
class MUForceCacheClear:
@classmethod
def INPUT_TYPES(s):
return {"required": {"model": ("MODEL",)}}
NOT_IDEMPOTENT = True
RETURN_TYPES = ("MODEL",)
FUNCTION = "do"
CATEGORY = "utils"
def do(self, model):
log.info("Running Python GC and clearing CUDA cache")
gc.collect()
comfy.model_management.soft_empty_cache(True)
return (model,)