Reduce Heroku Slug Size for Machine Learning (Python, PyTorch, Fastai)

Viewed 660

I am attempting to deploy a simple maching learning app to heroku but I keep exceeding the slug size requirement of 500MB, it looks like in the end I come up to about 1GB. Most of this appears to come from PyTorch for about 700MB.

Collecting torch>=1.0.0
   Downloading torch-1.6.0-cp36-cp36m-manylinux1_x86_64.whl (748.8 MB)

My requirements.txt file looks like

tensorboardX==1.6
opencv-python>=3.3.0.10
pillow>=6.2.1
flask
scikit-image
gunicorn
pandas

And the error message I get states I am over the slug size limit.

How can I only install the CPU version of PyTorch to get the slug size down?

2 Answers

Try adding the following lines to requirements.txt

-f https://download.pytorch.org/whl/torch_stable.html
torch==1.8.1+cpu
torchvision==0.9.1+cpu
fastai
voila
ipywidgets
Related