From d3df113fb07edb370e0f74b1e4e3b7b5a14a88dd Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Wed, 26 Oct 2022 16:52:31 -0400 Subject: [PATCH] When reduced_memory is True, on crash only move model back to Cpu. --- ui/sd_internal/runtime.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ui/sd_internal/runtime.py b/ui/sd_internal/runtime.py index 972a6062..3e0c6d34 100644 --- a/ui/sd_internal/runtime.py +++ b/ui/sd_internal/runtime.py @@ -374,9 +374,17 @@ def mk_img(req: Request): yield from do_mk_img(req) except Exception as e: print(traceback.format_exc()) - # Model crashed, release all resources in unknown state. - unload_models() - unload_filters() + + if thread_data.reduced_memory: + thread_data.modelFS.to('cpu') + thread_data.modelCS.to('cpu') + thread_data.model.model1.to("cpu") + thread_data.model.model2.to("cpu") + else: + # Model crashed, release all resources in unknown state. + unload_models() + unload_filters() + gc() # Release from memory. yield json.dumps({ "status": 'failed',