vae handle HIP OOM exceptions

This commit is contained in:
Alex Butler 2025-04-23 21:30:30 +01:00
parent 1883e70b43
commit 6b58f6bd5a
2 changed files with 11 additions and 2 deletions

View File

@ -235,6 +235,14 @@ try:
except:
OOM_EXCEPTION = Exception
def is_oom_exception(ex):
if isinstance(ex, OOM_EXCEPTION):
return True
# handle also other kinds of oom, e.g. "HIP error: out of memory"
msg = str(ex)
return "out of memory" in msg
XFORMERS_VERSION = ""
XFORMERS_ENABLED_VAE = True
if args.disable_xformers:

View File

@ -640,8 +640,9 @@ class VAE:
if samples is None:
samples = torch.empty((pixel_samples.shape[0],) + tuple(out.shape[1:]), device=self.output_device)
samples[x:x + batch_number] = out
except model_management.OOM_EXCEPTION:
except Exception as ex:
if not model_management.is_oom_exception(ex):
raise
logging.warning("Warning: Ran out of memory when regular VAE encoding, retrying with tiled VAE encoding.")
if self.latent_dim == 3:
tile = 256