From d25eb5d3858328d549bd00327b9f5fe2a768145d Mon Sep 17 00:00:00 2001 From: townwish4git Date: Mon, 19 Aug 2024 09:37:40 +0800 Subject: [PATCH] fix(sd3): fix deletion of text_encoders etc (#8951) Co-authored-by: Sayak Paul Co-authored-by: YiYi Xu --- examples/dreambooth/train_dreambooth_lora_sd3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/dreambooth/train_dreambooth_lora_sd3.py b/examples/dreambooth/train_dreambooth_lora_sd3.py index 163031968f..2e77cb946f 100644 --- a/examples/dreambooth/train_dreambooth_lora_sd3.py +++ b/examples/dreambooth/train_dreambooth_lora_sd3.py @@ -1454,7 +1454,7 @@ def main(args): ) # Clear the memory here - if not args.train_text_encoder and train_dataset.custom_instance_prompts: + if not args.train_text_encoder and not train_dataset.custom_instance_prompts: del tokenizers, text_encoders # Explicitly delete the objects as well, otherwise only the lists are deleted and the original references remain, preventing garbage collection del text_encoder_one, text_encoder_two, text_encoder_three