This commit is contained in:
lllyasviel
2024-02-04 14:30:58 -08:00
parent 112cef6066
commit 2954a36c18
2 changed files with 7 additions and 2 deletions

View File

@@ -49,7 +49,7 @@ class UpscalerLDSR(Upscaler):
return LDSR(model, yaml)
def do_upscale(self, img, path):
prepare_free_memory()
prepare_free_memory(aggressive=True)
try:
ldsr = self.load_model(path)
except Exception:

View File

@@ -9,7 +9,12 @@ from modules import modelloader, shared
from ldm_patched.modules import model_management
def prepare_free_memory():
def prepare_free_memory(aggressive=False):
if aggressive:
model_management.unload_all_models()
print('Upscale script freed all memory.')
return
model_management.free_memory(memory_required=1024*1024*3, device=model_management.get_torch_device())
print('Upscale script freed memory successfully.')