From 8e0881d9abfa4e139f2dbf3c9a072dd8d4b6d1ba Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:10:20 +0900 Subject: [PATCH] fix image upscale on cpu for some reason upscale using cpu will fail with RuntimeError: Inplace update to inference tensor outside InferenceMode switch from no_grad to inference_mode seems to have fixed it --- modules/upscaler_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/upscaler_utils.py b/modules/upscaler_utils.py index 5ecbbed96fd..a8408f05bca 100644 --- a/modules/upscaler_utils.py +++ b/modules/upscaler_utils.py @@ -41,7 +41,7 @@ def upscale_pil_patch(model, img: Image.Image) -> Image.Image: """ param = torch_utils.get_param(model) - with torch.no_grad(): + with torch.inference_mode(): tensor = pil_image_to_torch_bgr(img).unsqueeze(0) # add batch dimension tensor = tensor.to(device=param.device, dtype=param.dtype) with devices.without_autocast():