Add torch.xpu.empty_cache() to LDSR and SwinIR

This commit is contained in:
Disty0
2023-06-13 20:08:42 +03:00
parent 4951ed15f2
commit cb71d05d98
2 changed files with 5 additions and 1 deletions
@@ -113,6 +113,8 @@ class LDSR:
gc.collect()
if torch.cuda.is_available:
torch.cuda.empty_cache()
if shared.cmd_opts.use_ipex:
torch.xpu.empty_cache()
im_og = image
width_og, height_og = im_og.size
@@ -7,7 +7,7 @@ from tqdm.rich import tqdm
from swinir_model_arch import SwinIR as net
from swinir_model_arch_v2 import Swin2SR as net2
from modules import modelloader, devices, script_callbacks, shared
from modules.shared import opts, state
from modules.shared import cmd_opts, opts, state
from modules.upscaler import Upscaler, UpscalerData
@@ -44,6 +44,8 @@ class UpscalerSwinIR(Upscaler):
torch.cuda.empty_cache()
except Exception:
pass
if cmd_opts.use_ipex:
torch.xpu.empty_cache()
return img
def load_model(self, path, scale=4):