File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 5454)
5555from diffusers .loaders import StableDiffusionLoraLoaderMixin
5656from diffusers .optimization import get_scheduler
57- from diffusers .training_utils import _set_state_dict_into_text_encoder , cast_training_params
57+ from diffusers .training_utils import (
58+ _set_state_dict_into_text_encoder ,
59+ cast_training_params ,
60+ free_memory ,
61+ )
5862from diffusers .utils import (
5963 check_min_version ,
6064 convert_state_dict_to_diffusers ,
7579logger = get_logger (__name__ )
7680
7781
78- def free_memory ():
79- if torch .cuda .is_available ():
80- torch .cuda .empty_cache ()
81- if hasattr (torch , "xpu" ) and torch .xpu .is_available ():
82- torch .xpu .empty_cache ()
83-
84-
8582def save_model_card (
8683 repo_id : str ,
8784 images = None ,
Original file line number Diff line number Diff line change @@ -299,6 +299,8 @@ def free_memory():
299299 torch .mps .empty_cache ()
300300 elif is_torch_npu_available ():
301301 torch_npu .npu .empty_cache ()
302+ elif hasattr (torch , "xpu" ) and torch .xpu .is_available ():
303+ torch .xpu .empty_cache ()
302304
303305
304306# Adapted from torch-ema https://github.com/fadel/pytorch_ema/blob/master/torch_ema/ema.py#L14
You can’t perform that action at this time.
0 commit comments