When reduced_memory is True, on crash only move model back to Cpu.

This commit is contained in:
Marc-Andre Ferland 2022-10-26 16:52:31 -04:00
parent ae40b6ba8c
commit d3df113fb0

View File

@ -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',