mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-25 15:55:18 +00:00
Fix potential issue if exception happens when patching model.
This commit is contained in:
parent
ef90e9c376
commit
149a4de3f2
4
nodes.py
4
nodes.py
@ -289,6 +289,7 @@ def common_ksampler(device, model, seed, steps, cfg, sampler_name, scheduler, po
|
|||||||
else:
|
else:
|
||||||
noise = torch.randn(latent_image.size(), dtype=latent_image.dtype, layout=latent_image.layout, generator=torch.manual_seed(seed), device="cpu")
|
noise = torch.randn(latent_image.size(), dtype=latent_image.dtype, layout=latent_image.layout, generator=torch.manual_seed(seed), device="cpu")
|
||||||
|
|
||||||
|
real_model = None
|
||||||
try:
|
try:
|
||||||
real_model = model.patch_model()
|
real_model = model.patch_model()
|
||||||
real_model.to(device)
|
real_model.to(device)
|
||||||
@ -322,7 +323,8 @@ def common_ksampler(device, model, seed, steps, cfg, sampler_name, scheduler, po
|
|||||||
real_model.cpu()
|
real_model.cpu()
|
||||||
model.unpatch_model()
|
model.unpatch_model()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
real_model.cpu()
|
if real_model is not None:
|
||||||
|
real_model.cpu()
|
||||||
model.unpatch_model()
|
model.unpatch_model()
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user