fix DDP SDXL training

This commit is contained in:
Isotr0py
2023-12-12 19:58:44 +08:00
parent 4a2cef887c
commit bb5ae389f7
2 changed files with 14 additions and 2 deletions

View File

@@ -398,6 +398,9 @@ def train(args):
if train_unet:
unet = accelerator.prepare(unet)
if train_text_encoder1:
# freeze last layer and final_layer_norm in te1 since we use the output of the penultimate layer
text_encoder1.text_model.encoder.layers[-1].requires_grad_(False)
text_encoder1.text_model.final_layer_norm.requires_grad_(False)
text_encoder1 = accelerator.prepare(text_encoder1)
if train_text_encoder2:
text_encoder2 = accelerator.prepare(text_encoder2)