Skip to content

Commit

Permalink
fix image upscale on cpu
Browse files Browse the repository at this point in the history
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
  • Loading branch information
w-e-w committed Jul 27, 2024
1 parent 834297b commit 8e0881d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/upscaler_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 8e0881d

Please sign in to comment.