Skip to content

Commit ab3cd4f

Browse files
committed
Improve the performance and suitable for NPU computing
1 parent e2f0a7b commit ab3cd4f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/text_to_image/train_text_to_image_sdxl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ def preprocess_train(examples):
938938
gc.collect()
939939
if is_torch_npu_available():
940940
torch_npu.npu.empty_cache()
941-
else:
941+
elif torch.cuda.is_available():
942942
torch.cuda.empty_cache()
943943

944944
def collate_fn(examples):
@@ -1266,7 +1266,7 @@ def compute_time_ids(original_size, crops_coords_top_left):
12661266
del pipeline
12671267
if is_torch_npu_available():
12681268
torch_npu.npu.empty_cache()
1269-
else:
1269+
elif torch.cuda.is_available():
12701270
torch.cuda.empty_cache()
12711271

12721272
if args.use_ema:

0 commit comments

Comments
 (0)