mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-08 22:35:09 +00:00
Refactor memory cleaning into a single function
This commit is contained in:
@@ -66,6 +66,7 @@ import diffusers
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
from library.device_utils import clean_memory
|
||||
from library.ipex_interop import init_ipex
|
||||
|
||||
init_ipex()
|
||||
@@ -888,8 +889,7 @@ class PipelineLike:
|
||||
init_latent_dist = self.vae.encode(init_image).latent_dist
|
||||
init_latents = init_latent_dist.sample(generator=generator)
|
||||
else:
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.empty_cache()
|
||||
clean_memory()
|
||||
init_latents = []
|
||||
for i in tqdm(range(0, min(batch_size, len(init_image)), vae_batch_size)):
|
||||
init_latent_dist = self.vae.encode(
|
||||
@@ -1047,8 +1047,7 @@ class PipelineLike:
|
||||
if vae_batch_size >= batch_size:
|
||||
image = self.vae.decode(latents).sample
|
||||
else:
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.empty_cache()
|
||||
clean_memory()
|
||||
images = []
|
||||
for i in tqdm(range(0, batch_size, vae_batch_size)):
|
||||
images.append(
|
||||
|
||||
Reference in New Issue
Block a user