Skip to content

Commit

Permalink
[python] Add more OOM handling (#2515)
Browse files Browse the repository at this point in the history
  • Loading branch information
xyang16 authored Nov 4, 2024
1 parent 8e6d936 commit 481f184
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions engines/python/setup/djl_python_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ def run_server(self):
f"Invalid output type: {type(outputs)}")
except Exception as e:
logging.exception("Failed invoke service.invoke_handler()")
if type(e).__name__ == "OutOfMemoryError" or type(
e).__name__ == "MemoryError":
if (type(e).__name__ == "OutOfMemoryError"
or type(e).__name__ == "MemoryError"
or "No available memory for the cache blocks" in str(e)
or "CUDA error: out of memory" in str(e)):
outputs = Output(code=507, message=str(e))
else:
outputs = Output().error(str(e))
Expand Down

0 comments on commit 481f184

Please sign in to comment.