From f7715d39f3bf0fe7c289a4b3399b26f2ba7c99dc Mon Sep 17 00:00:00 2001 From: huchenlei Date: Fri, 10 May 2024 23:47:30 -0400 Subject: [PATCH] Prevent PuLID preprocessor unload. Temp Fix VRAM leak. --- scripts/supported_preprocessor.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/supported_preprocessor.py b/scripts/supported_preprocessor.py index 473d6203c..179c33227 100644 --- a/scripts/supported_preprocessor.py +++ b/scripts/supported_preprocessor.py @@ -176,7 +176,21 @@ def tag_to_filters(cls, tag: str) -> Set[str]: @classmethod def unload_unused(cls, active_processors: Set["Preprocessor"]): + # Prevent unloading for following preprocessors. + # https://github.com/Mikubill/sd-webui-controlnet/issues/2862 + # TODO: Investigate proper way to unload PuLID. + # Current unloading method will cause VRAM leak. It is suspected + # the current unload method causes new model to load each time + # preprocessor is called. + prevent_unload = [ + "EVA02-CLIP-L-14-336", + "facexlib", + "ip-adapter_pulid", + ] for p in cls.all_processors.values(): + if p.label in prevent_unload: + continue + if p not in active_processors: success = p.unload() if success: