Fastai library too large for heroku

Hello everyone, I encounter a problem today when deploying an application with fastai v2 to heroku free server.
The problem is the slug size too large which exceeds 500MB. Most of it comes from fastai and its dependencies.

What should I do to reduce the slug size? Thanks in advance.

You should use the pytorch-cpu package when deploying to heroku, this significantly reduces the deployment size. Here’s a related StackOverflow thread


I come back to confirm for anyone encounter. This approach works. Thank you Raphi.

1 Like

I spent a while fiddling around with different package versions. I got things working so I figured I’d share my requirements.txt.

This works on Heroku-20 stack on python 3.8.

It produces a slug of 366 MB which is still pretty large – I wish there was a good way to trim down some of the dependencies for fastai for a smaller serving library.