Streamlit app with PyTorch/HuggingFace Transformers crashes when deployed to Heroku

Hi everyone! :wave:

My very first thread - it’s great to be here! :slight_smile:

I’ve an issue with a Streamlit app leveraging Pytorch with the distilbart-mnli-12-3 HuggingFace model.

I can’t seem to deploy it correctly on Heroku. I’ve tried various configs but once deployed the app crashes all time. Here’s the log trace I got from Heroku: https://pastebin.com/uzEYVQy9

It looks like the app is crashing due to memory issues, the error being:

1. at=error code=H10 desc="App crashed" method=GET path="/healthz" host=still-basin-69776.herokuapp.com request_id=54a25884-8fba-4c36-ad08-441237858746 fwd="95.144.3.223" dyno= connect= service= status=503 bytes= protocol=https

Here’s the python code: https://github.com/CharlyWargnier/TransformersZeroShotHerokuFiles/blob/main/app.py

If needs be, I’ve also pasted all the files related to the Heroku deployment including the python file and the requirements.txt in this repo:

Thanks in advance for your help! :pray:

Charly