Skip to content

Commit 44f6bc8

Browse files
authored
Don't copy when unwrapping model (huggingface#2166)
* Don't copy when unwrapping model. Otherwise an exception is raised when using fp16. * Remove unused import
1 parent 164b6e0 commit 44f6bc8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

examples/unconditional_image_generation/train_unconditional.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import argparse
2-
import copy
32
import inspect
43
import logging
54
import math
@@ -530,7 +529,7 @@ def transforms(examples):
530529
# Generate sample images for visual inspection
531530
if accelerator.is_main_process:
532531
if epoch % args.save_images_epochs == 0 or epoch == args.num_epochs - 1:
533-
unet = copy.deepcopy(accelerator.unwrap_model(model))
532+
unet = accelerator.unwrap_model(model)
534533
if args.use_ema:
535534
ema_model.copy_to(unet.parameters())
536535
pipeline = DDPMPipeline(

0 commit comments

Comments
 (0)