Merge pull request #398 from madrang/mGpu-crashHandling

mGpu crash handling
This commit is contained in:
cmdr2 2022-10-27 13:44:26 +05:30 committed by GitHub
commit 3fb5d886dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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