Unverified Commit a98a839d authored by Leo Jiang's avatar Leo Jiang Committed by GitHub
Browse files

Reduce Memory Cost in Flux Training (#9829)



* Improve NPU performance

* Improve NPU performance

* Improve NPU performance

* Improve NPU performance

* [bugfix] bugfix for npu free memory

* [bugfix] bugfix for npu free memory

* [bugfix] bugfix for npu free memory

* Reduce memory cost for flux training process

---------
Co-authored-by: default avatar蒋硕 <jiangshuo9@h-partners.com>
Co-authored-by: default avatarSayak Paul <spsayakpaul@gmail.com>
parent 3deed729
...@@ -1740,6 +1740,9 @@ def main(args): ...@@ -1740,6 +1740,9 @@ def main(args):
torch_npu.npu.empty_cache() torch_npu.npu.empty_cache()
gc.collect() gc.collect()
images = None
del pipeline
# Save the lora layers # Save the lora layers
accelerator.wait_for_everyone() accelerator.wait_for_everyone()
if accelerator.is_main_process: if accelerator.is_main_process:
...@@ -1798,6 +1801,9 @@ def main(args): ...@@ -1798,6 +1801,9 @@ def main(args):
ignore_patterns=["step_*", "epoch_*"], ignore_patterns=["step_*", "epoch_*"],
) )
images = None
del pipeline
accelerator.end_training() accelerator.end_training()
......
...@@ -1844,6 +1844,9 @@ def main(args): ...@@ -1844,6 +1844,9 @@ def main(args):
del text_encoder_one, text_encoder_two del text_encoder_one, text_encoder_two
free_memory() free_memory()
images = None
del pipeline
# Save the lora layers # Save the lora layers
accelerator.wait_for_everyone() accelerator.wait_for_everyone()
if accelerator.is_main_process: if accelerator.is_main_process:
...@@ -1908,6 +1911,9 @@ def main(args): ...@@ -1908,6 +1911,9 @@ def main(args):
ignore_patterns=["step_*", "epoch_*"], ignore_patterns=["step_*", "epoch_*"],
) )
images = None
del pipeline
accelerator.end_training() accelerator.end_training()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment