pythonherokupytorchtorchserve

Heroku torchserve app crashed, exited with status 0


I'm deploying torchserve on heroku free dyno. Deploy works fine but the app isn't running properly.

LOG1:

2022-03-17T02:11:10.352655+00:00 heroku[web.1]: Starting process with command `torchserve --start --ncs --model-store model_store --models squeezenet1_1.mar`
2022-03-17T02:11:11.558957+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2022-03-17T02:11:11.701395+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2022-03-17T02:11:11.896962+00:00 heroku[web.1]: Process exited with status 0
2022-03-17T02:11:12.059922+00:00 heroku[web.1]: State changed from starting to crashed

LOG2:

2022-03-17T05:17:29.472219+00:00 heroku[web.1]: Starting process with command `torchserve --start --ncs --model-store model_store --models squeezenet1_1.mar`
2022-03-17T05:17:30.854303+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2022-03-17T05:17:31.304897+00:00 heroku[web.1]: Process exited with status 0
2022-03-17T05:17:31.364160+00:00 heroku[web.1]: State changed from starting to crashed

Also, my requirements.txt:

-f https://download.pytorch.org/whl/cpu/torch_stable.html
future
psutil
requests
captum
packaging
numpy
cython
wheel
pillow==9.0.1
torch==1.10.0+cpu
torchvision==0.11.1+cpu
torchaudio==0.10.0+cpu
torchtext==0.11.0
torchserve==0.5.3

runtime.txt

python-3.8.12

system.properties

java.runtime.version=1.8.0_322

Solution

  • Problem was torchserve was running in background mode by default. Adding --foreground to the torchserve command in Procfile fixed this. (Also, java runtime 11.0.14.1 is required by torchserve)