From 2f2d356e4ce331a5c475f7d04adfd1c15d966dcf Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Thu, 29 Sep 2022 11:32:12 +0300 Subject: [PATCH] call torch_gc before/after each gpu gradio operation --- webui.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webui.py b/webui.py index c70a11c7..39f9ae9a 100644 --- a/webui.py +++ b/webui.py @@ -1,6 +1,7 @@ import os import threading +from modules import devices from modules.paths import script_path import signal @@ -47,6 +48,8 @@ def wrap_queued_call(func): def wrap_gradio_gpu_call(func): def f(*args, **kwargs): + devices.torch_gc() + shared.state.sampling_step = 0 shared.state.job_count = -1 shared.state.job_no = 0 @@ -62,6 +65,8 @@ def wrap_gradio_gpu_call(func): shared.state.job = "" shared.state.job_count = 0 + devices.torch_gc() + return res return modules.ui.wrap_gradio_call(f)