Skip to content

Commit

Permalink
fix sampling in training with mutiple gpus ref #989
Browse files Browse the repository at this point in the history
  • Loading branch information
kohya-ss committed Dec 15, 2023
1 parent 7adcd9c commit 3efd90b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion library/train_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4603,7 +4603,7 @@ def line_to_prompt_dict(line: str) -> dict:

def sample_images_common(
pipe_class,
accelerator,
accelerator: Accelerator,
args: argparse.Namespace,
epoch,
steps,
Expand Down Expand Up @@ -4640,6 +4640,13 @@ def sample_images_common(
org_vae_device = vae.device # CPUにいるはず
vae.to(device)

# unwrap unet and text_encoder(s)
unet = accelerator.unwrap_model(unet)
if isinstance(text_encoder, (list, tuple)):
text_encoder = [accelerator.unwrap_model(te) for te in text_encoder]
else:
text_encoder = accelerator.unwrap_model(text_encoder)

# read prompts

# with open(args.sample_prompts, "rt", encoding="utf-8") as f:
Expand Down

0 comments on commit 3efd90b

Please sign in to comment.