Skip to content

Commit

Permalink
[Sana 4K] Add vae tiling option to avoid OOM (#10583)
Browse files Browse the repository at this point in the history
Co-authored-by: J石页 <[email protected]>
  • Loading branch information
leisuzz and J石页 authored Jan 15, 2025
1 parent c944f06 commit b0c8973
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/dreambooth/train_dreambooth_lora_sana.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def log_validation(
f"Running validation... \n Generating {args.num_validation_images} images with prompt:"
f" {args.validation_prompt}."
)
if args.enable_vae_tiling:
pipeline.vae.enable_tiling(tile_sample_min_height=1024, tile_sample_stride_width=1024)

pipeline.text_encoder = pipeline.text_encoder.to(torch.bfloat16)
pipeline = pipeline.to(accelerator.device)
pipeline.set_progress_bar_config(disable=True)
Expand Down Expand Up @@ -597,6 +600,7 @@ def parse_args(input_args=None):
help="Whether to offload the VAE and the text encoder to CPU when they are not used.",
)
parser.add_argument("--local_rank", type=int, default=-1, help="For distributed training: local_rank")
parser.add_argument("--enable_vae_tiling", action="store_true", help="Enabla vae tiling in log validation")

if input_args is not None:
args = parser.parse_args(input_args)
Expand Down

0 comments on commit b0c8973

Please sign in to comment.