Voila Deployment on Heroku: Compiled slug size too large

When following the instructions for Voila Deployment on Heroku, I’m getting this error:

Compiled slug size: 990.3M is too large (max is 500M).

My app is very similar to the bear classifier app, so I’m wondering why this may be happening? Is the fastai library itself too large perhaps? Thanks in advance for any suggestions! :slight_smile:

1 Like

Check and see if you are using torch-cpu instead of the usual PyTorch installation for GPU? You don’t anyway get GPU on Heroku so the GPU-specific features wouldn’t be used.

Sorry, I’m not sure how to do that. I copied the requirements.txt directly from the bear voila repo, and here are the contents:

voila
fastai>=2
pillow<7
packaging
ipywidgets==7.5.1

It looks like it just includes torchvision>=0.7 and torch>=1.6.0, I don’t see any torch-cpu. Here are the complete Heroku logs in case that helps:

-----> Python app detected
 !     Python has released a security update! Please consider upgrading to python-3.7.9
       Learn More: https://devcenter.heroku.com/articles/python-runtimes
-----> Installing python-3.7.3
-----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
-----> Installing SQLite3
-----> Installing requirements with pip
       Collecting voila
         Downloading voila-0.1.22-py3-none-any.whl (5.9 MB)
       Collecting fastai>=2
         Downloading fastai-2.0.6-py3-none-any.whl (353 kB)
       Collecting pillow<7
         Downloading Pillow-6.2.2-cp37-cp37m-manylinux1_x86_64.whl (2.1 MB)
       Collecting packaging
         Downloading packaging-20.4-py2.py3-none-any.whl (37 kB)
       Collecting ipywidgets==7.5.1
         Downloading ipywidgets-7.5.1-py2.py3-none-any.whl (121 kB)
       Collecting jupyter-server<0.2.0,>=0.1.0
         Downloading jupyter_server-0.1.1-py2.py3-none-any.whl (183 kB)
       Collecting nbconvert<6,>=5.5.0
         Downloading nbconvert-5.6.1-py2.py3-none-any.whl (455 kB)
       Collecting async-generator
         Downloading async_generator-1.10-py3-none-any.whl (18 kB)
       Collecting jupyterlab-pygments<0.2,>=0.1.0
         Downloading jupyterlab_pygments-0.1.1-py2.py3-none-any.whl (4.6 kB)
       Collecting pygments<3,>=2.4.1
         Downloading Pygments-2.6.1-py3-none-any.whl (914 kB)
       Collecting spacy
         Downloading spacy-2.3.2-cp37-cp37m-manylinux1_x86_64.whl (9.9 MB)
       Collecting matplotlib
         Downloading matplotlib-3.3.1-cp37-cp37m-manylinux1_x86_64.whl (11.6 MB)
       Collecting fastprogress>=0.2.4
         Downloading fastprogress-1.0.0-py3-none-any.whl (12 kB)
       Collecting requests
         Downloading requests-2.24.0-py2.py3-none-any.whl (61 kB)
       Collecting pandas>=1.1.0
         Downloading pandas-1.1.1-cp37-cp37m-manylinux1_x86_64.whl (10.5 MB)
       Collecting pyyaml
         Downloading PyYAML-5.3.1.tar.gz (269 kB)
       Collecting scikit-learn
         Downloading scikit_learn-0.23.2-cp37-cp37m-manylinux1_x86_64.whl (6.8 MB)
       Collecting scipy
         Downloading scipy-1.5.2-cp37-cp37m-manylinux1_x86_64.whl (25.9 MB)
       Collecting torchvision>=0.7
         Downloading torchvision-0.7.0-cp37-cp37m-manylinux1_x86_64.whl (5.9 MB)
       Collecting torch>=1.6.0
         Downloading torch-1.6.0-cp37-cp37m-manylinux1_x86_64.whl (748.8 MB)
       Collecting fastcore>=1.0.0
         Downloading fastcore-1.0.0-py3-none-any.whl (36 kB)
       Collecting pyparsing>=2.0.2
         Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
       Collecting six
         Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
       Collecting traitlets>=4.3.1
         Downloading traitlets-4.3.3-py2.py3-none-any.whl (75 kB)
       Collecting ipykernel>=4.5.1
         Downloading ipykernel-5.3.4-py3-none-any.whl (120 kB)
       Collecting nbformat>=4.2.0
         Downloading nbformat-5.0.7-py3-none-any.whl (170 kB)
       Collecting widgetsnbextension~=3.5.0
         Downloading widgetsnbextension-3.5.1-py2.py3-none-any.whl (2.2 MB)
       Collecting ipython>=4.0.0; python_version >= "3.3"
         Downloading ipython-7.18.1-py3-none-any.whl (786 kB)
       Collecting prometheus-client
         Downloading prometheus_client-0.8.0-py2.py3-none-any.whl (53 kB)
       Collecting pyzmq>=17
         Downloading pyzmq-19.0.2-cp37-cp37m-manylinux1_x86_64.whl (1.1 MB)
       Collecting tornado>=4
         Downloading tornado-6.0.4.tar.gz (496 kB)
       Collecting ipython-genutils
         Downloading ipython_genutils-0.2.0-py2.py3-none-any.whl (26 kB)
       Collecting Send2Trash
         Downloading Send2Trash-1.5.0-py3-none-any.whl (12 kB)
       Collecting terminado>=0.8.1
         Downloading terminado-0.8.3-py2.py3-none-any.whl (33 kB)
       Collecting jupyter-client>=5.3.1
         Downloading jupyter_client-6.1.7-py3-none-any.whl (108 kB)
       Collecting jupyter-core>=4.4.0
         Downloading jupyter_core-4.6.3-py2.py3-none-any.whl (83 kB)
       Collecting jinja2
         Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
       Collecting testpath
         Downloading testpath-0.4.4-py2.py3-none-any.whl (163 kB)
       Collecting bleach
         Downloading bleach-3.1.5-py2.py3-none-any.whl (151 kB)
       Collecting entrypoints>=0.2.2
         Downloading entrypoints-0.3-py2.py3-none-any.whl (11 kB)
       Collecting defusedxml
         Downloading defusedxml-0.6.0-py2.py3-none-any.whl (23 kB)
       Collecting mistune<2,>=0.8.1
         Downloading mistune-0.8.4-py2.py3-none-any.whl (16 kB)
       Collecting pandocfilters>=1.4.1
         Downloading pandocfilters-1.4.2.tar.gz (14 kB)
       Collecting cymem<2.1.0,>=2.0.2
         Downloading cymem-2.0.3-cp37-cp37m-manylinux1_x86_64.whl (32 kB)
       Collecting catalogue<1.1.0,>=0.0.7
         Downloading catalogue-1.0.0-py2.py3-none-any.whl (7.7 kB)
       Collecting murmurhash<1.1.0,>=0.28.0
         Downloading murmurhash-1.0.2-cp37-cp37m-manylinux1_x86_64.whl (19 kB)
       Collecting plac<1.2.0,>=0.9.6
         Downloading plac-1.1.3-py2.py3-none-any.whl (20 kB)
       Collecting srsly<1.1.0,>=1.0.2
         Downloading srsly-1.0.2-cp37-cp37m-manylinux1_x86_64.whl (185 kB)
       Collecting preshed<3.1.0,>=3.0.2
         Downloading preshed-3.0.2-cp37-cp37m-manylinux1_x86_64.whl (118 kB)
       Collecting blis<0.5.0,>=0.4.0
         Downloading blis-0.4.1-cp37-cp37m-manylinux1_x86_64.whl (3.7 MB)
       Collecting tqdm<5.0.0,>=4.38.0
         Downloading tqdm-4.48.2-py2.py3-none-any.whl (68 kB)
       Collecting numpy>=1.15.0
         Downloading numpy-1.19.1-cp37-cp37m-manylinux2010_x86_64.whl (14.5 MB)
       Collecting thinc==7.4.1
         Downloading thinc-7.4.1-cp37-cp37m-manylinux1_x86_64.whl (2.1 MB)
       Collecting wasabi<1.1.0,>=0.4.0
         Downloading wasabi-0.8.0-py3-none-any.whl (23 kB)
       Collecting python-dateutil>=2.1
         Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
       Collecting cycler>=0.10
         Downloading cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
       Collecting certifi>=2020.06.20
         Downloading certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
       Collecting kiwisolver>=1.0.1
         Downloading kiwisolver-1.2.0-cp37-cp37m-manylinux1_x86_64.whl (88 kB)
       Collecting chardet<4,>=3.0.2
         Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
       Collecting idna<3,>=2.5
         Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
       Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
         Downloading urllib3-1.25.10-py2.py3-none-any.whl (127 kB)
       Collecting pytz>=2017.2
         Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
       Collecting joblib>=0.11
         Downloading joblib-0.16.0-py3-none-any.whl (300 kB)
       Collecting threadpoolctl>=2.0.0
         Downloading threadpoolctl-2.1.0-py3-none-any.whl (12 kB)
       Collecting future
         Downloading future-0.18.2.tar.gz (829 kB)
       Collecting dataclasses
         Downloading dataclasses-0.6-py3-none-any.whl (14 kB)
       Collecting decorator
         Downloading decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
       Collecting jsonschema!=2.5.0,>=2.4
         Downloading jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
       Collecting notebook>=4.4.1
         Downloading notebook-6.1.3-py3-none-any.whl (9.4 MB)
       Collecting pickleshare
         Downloading pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB)
       Collecting jedi>=0.10
         Downloading jedi-0.17.2-py2.py3-none-any.whl (1.4 MB)
       Collecting prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0
         Downloading prompt_toolkit-3.0.7-py3-none-any.whl (355 kB)
       Collecting backcall
         Downloading backcall-0.2.0-py2.py3-none-any.whl (11 kB)
       Collecting pexpect>4.3; sys_platform != "win32"
         Downloading pexpect-4.8.0-py2.py3-none-any.whl (59 kB)
       Collecting ptyprocess; os_name != "nt"
         Downloading ptyprocess-0.6.0-py2.py3-none-any.whl (39 kB)
       Collecting MarkupSafe>=0.23
         Downloading MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl (27 kB)
       Collecting webencodings
         Downloading webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
       Collecting importlib-metadata>=0.20; python_version < "3.8"
         Downloading importlib_metadata-1.7.0-py2.py3-none-any.whl (31 kB)
       Collecting attrs>=17.4.0
         Downloading attrs-20.1.0-py2.py3-none-any.whl (49 kB)
       Collecting pyrsistent>=0.14.0
         Downloading pyrsistent-0.16.0.tar.gz (108 kB)
       Collecting argon2-cffi
         Downloading argon2_cffi-20.1.0-cp35-abi3-manylinux1_x86_64.whl (97 kB)
       Collecting parso<0.8.0,>=0.7.0
         Downloading parso-0.7.1-py2.py3-none-any.whl (109 kB)
       Collecting wcwidth
         Downloading wcwidth-0.2.5-py2.py3-none-any.whl (30 kB)
       Collecting zipp>=0.5
         Downloading zipp-3.1.0-py3-none-any.whl (4.9 kB)
       Collecting cffi>=1.0.0
         Downloading cffi-1.14.2-cp37-cp37m-manylinux1_x86_64.whl (401 kB)
       Collecting pycparser
         Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
       Building wheels for collected packages: pyyaml, tornado, pandocfilters, future, pyrsistent
         Building wheel for pyyaml (setup.py): started
         Building wheel for pyyaml (setup.py): finished with status 'done'
         Created wheel for pyyaml: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=393878 sha256=f5ba3f933a47ba3289760a850e301a648ef08a14605cb5571e205d0948144441
         Stored in directory: /tmp/pip-ephem-wheel-cache-fcqjrnvl/wheels/5e/03/1e/e1e954795d6f35dfc7b637fe2277bff021303bd9570ecea653
         Building wheel for tornado (setup.py): started
         Building wheel for tornado (setup.py): finished with status 'done'
         Created wheel for tornado: filename=tornado-6.0.4-cp37-cp37m-linux_x86_64.whl size=428543 sha256=c2c60e5191ba13b4a74789afcf351b1ea080b332456e07b1169692982e560915
         Stored in directory: /tmp/pip-ephem-wheel-cache-fcqjrnvl/wheels/7d/14/fa/d88fb5da77d813ea0ffca38a2ab2a052874e9e1142bad0b348
         Building wheel for pandocfilters (setup.py): started
         Building wheel for pandocfilters (setup.py): finished with status 'done'
         Created wheel for pandocfilters: filename=pandocfilters-1.4.2-py3-none-any.whl size=7856 sha256=9b8713f8196bbb575d856aca1c87ed185052310fc1a9aec6c70f5dec18673b5c
         Stored in directory: /tmp/pip-ephem-wheel-cache-fcqjrnvl/wheels/63/99/01/9fe785b86d1e091a6b2a61e06ddb3d8eb1bc9acae5933d4740
         Building wheel for future (setup.py): started
         Building wheel for future (setup.py): finished with status 'done'
         Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491058 sha256=4edcb3617c54232ecb905ea54730a27e551c79cb6a236e26f1c02102efff0147
         Stored in directory: /tmp/pip-ephem-wheel-cache-fcqjrnvl/wheels/56/b0/fe/4410d17b32f1f0c3cf54cdfb2bc04d7b4b8f4ae377e2229ba0
         Building wheel for pyrsistent (setup.py): started
         Building wheel for pyrsistent (setup.py): finished with status 'done'
         Created wheel for pyrsistent: filename=pyrsistent-0.16.0-cp37-cp37m-linux_x86_64.whl size=115993 sha256=cc124ccf175565f1863bbc1cbfca1edf0b1ab5702ecf541a2e95374270337eae
         Stored in directory: /tmp/pip-ephem-wheel-cache-fcqjrnvl/wheels/22/52/11/f0920f95c23ed7d2d0b05f2b7b2f4509e87a20cfe8ea43d987
       Successfully built pyyaml tornado pandocfilters future pyrsistent
       Installing collected packages: ipython-genutils, six, decorator, traitlets, prometheus-client, pyzmq, tornado, jupyter-core, python-dateutil, jupyter-client, pickleshare, parso, jedi, pygments, wcwidth, prompt-toolkit, backcall, ptyprocess, pexpect, ipython, ipykernel, Send2Trash, terminado, testpath, webencodings, pyparsing, packaging, bleach, entrypoints, MarkupSafe, jinja2, defusedxml, zipp, importlib-metadata, attrs, pyrsistent, jsonschema, nbformat, mistune, pandocfilters, nbconvert, jupyter-server, async-generator, jupyterlab-pygments, voila, cymem, catalogue, murmurhash, certifi, chardet, idna, urllib3, requests, plac, srsly, preshed, numpy, blis, tqdm, wasabi, thinc, spacy, pillow, cycler, kiwisolver, matplotlib, fastprogress, pytz, pandas, pyyaml, joblib, scipy, threadpoolctl, scikit-learn, future, torch, torchvision, dataclasses, fastcore, fastai, pycparser, cffi, argon2-cffi, notebook, widgetsnbextension, ipywidgets
       Successfully installed MarkupSafe-1.1.1 Send2Trash-1.5.0 argon2-cffi-20.1.0 async-generator-1.10 attrs-20.1.0 backcall-0.2.0 bleach-3.1.5 blis-0.4.1 catalogue-1.0.0 certifi-2020.6.20 cffi-1.14.2 chardet-3.0.4 cycler-0.10.0 cymem-2.0.3 dataclasses-0.6 decorator-4.4.2 defusedxml-0.6.0 entrypoints-0.3 fastai-2.0.6 fastcore-1.0.0 fastprogress-1.0.0 future-0.18.2 idna-2.10 importlib-metadata-1.7.0 ipykernel-5.3.4 ipython-7.18.1 ipython-genutils-0.2.0 ipywidgets-7.5.1 jedi-0.17.2 jinja2-2.11.2 joblib-0.16.0 jsonschema-3.2.0 jupyter-client-6.1.7 jupyter-core-4.6.3 jupyter-server-0.1.1 jupyterlab-pygments-0.1.1 kiwisolver-1.2.0 matplotlib-3.3.1 mistune-0.8.4 murmurhash-1.0.2 nbconvert-5.6.1 nbformat-5.0.7 notebook-6.1.3 numpy-1.19.1 packaging-20.4 pandas-1.1.1 pandocfilters-1.4.2 parso-0.7.1 pexpect-4.8.0 pickleshare-0.7.5 pillow-6.2.2 plac-1.1.3 preshed-3.0.2 prometheus-client-0.8.0 prompt-toolkit-3.0.7 ptyprocess-0.6.0 pycparser-2.20 pygments-2.6.1 pyparsing-2.4.7 pyrsistent-0.16.0 python-dateutil-2.8.1 pytz-2020.1 pyyaml-5.3.1 pyzmq-19.0.2 requests-2.24.0 scikit-learn-0.23.2 scipy-1.5.2 six-1.15.0 spacy-2.3.2 srsly-1.0.2 terminado-0.8.3 testpath-0.4.4 thinc-7.4.1 threadpoolctl-2.1.0 torch-1.6.0 torchvision-0.7.0 tornado-6.0.4 tqdm-4.48.2 traitlets-4.3.3 urllib3-1.25.10 voila-0.1.22 wasabi-0.8.0 wcwidth-0.2.5 webencodings-0.5.1 widgetsnbextension-3.5.1 zipp-3.1.0
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
 !     Compiled slug size: 990.3M is too large (max is 500M).
 !     See: http://devcenter.heroku.com/articles/slug-size
 !     Push failed

You need to specify the cpu version of torch in the requirements.txt file:

Thanks, I’ll try this out! But if I specify fastai>=2 in my requirements, won’t it automatically get install the GPU version of torch? Or is there some way I can override this? Sorry, I don’t know much about how pip works.

I don’t think this should be a problem. It worked fine for fastai1 so it should be fine for fastai2 as well.

I have faced this issue too, so I completely avoided Voila route, by exporting model as pkl file and then building and deploying my model as a web app via docker image on Heroku, You can find more details here => Deployment ready template for creating responsive web app for Fastai2 Vision models

3 Likes

Sorry, gave you the wheel file path for Pytorch version 1.1 where it supposes to be v.1.6
Try to change requirements.txt to the following:

voila
https://download.pytorch.org/whl/cpu/torch-1.6.0%2Bcpu-cp36-cp36m-linux_x86_64.whl 
fastai>=2
pillow<7
packaging
ipywidgets==7.5.1

You can check my repo, I used Streamlit and deployed it through Heroku

The way I did it was just copying the requirements.txt file of someone who already has a site up and running. That way, I did not have to go through the tedious process of trial-and-error to get ‘slug size’ below 500 MB.

I have a website deployd on Heroku- https://folk-ai.herokuapp.com. You can visit the site and go to the GitHub repo to look at the requirements file.

But it uses fastai v1. And it does not uses voila.

I’m getting errors for each version from list of torch stable versions. like

`{specific_version} is not a supported wheel on this platform

Try to put this into your requirements.txt(it’s image)

// requirements.txt

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