Search code examples
tensorflowherokustreamlit

Tensorflow Apps No Longer Deploying To Heroku: Slug Size Too Large


I have a number of heroku applications that I've been able to update pretty seamlessly until recently. They make use of tensorflow and streamlit, and all give off similar messages on deployment:

-----> Compressing...
remote:  !     Compiled slug size: 560.2M is too large (max is 500M).
remote:  !     See: http://devcenter.heroku.com/articles/slug-size
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 5c0f686a86459f6e81627ce14770f7494f4bd244
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 5c0f686a86459f6e81627ce14770f7494f4bd244
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to dry-caverns-08193.
remote:
To https://git.heroku.com/dry-caverns-08193.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/dry-caverns-08193.git'

I know it says the slug size is too large, but they have run previously with the same message, so I'm not sure that's what the issue is.

Here's my file setup:

app.py
Procfile
requirements.txt
setup.sh
my_model/
  -- assets/
  -- variables/
       -- variables.index
       -- variables.data-00000-of-000001
  saved_model.pb

requirements.txt reads as follows:

tensorflow==2.*
streamlit==0.67.0
requests==2.24.0
requests-oauthlib==1.3.0

setup.sh reads as follows:

mkdir -p ~/.streamlit/
echo "\
[general]\n\
email = \"[email protected]\"\n\
" > ~/.streamlit/credentials.toml
echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" > ~/.streamlit/config.toml

My immediate suspicion is that tensorflow is causing the slug size to be too large -- but again it worked w/ tensorflow previously, so I"m not sure why it would not work now.

Is there anything else it could be?

EDIT:

After looking at this question: Heroku: If you are developing on a branch and deploying via git you must run: I tried git push heroku master:main, but that did not work with the following displaying in the logs:

Push rejected to dry-caverns-08193.
remote:
To https://git.heroku.com/dry-caverns-08193.git
 ! [remote rejected] master -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/dry-caverns-08193.git'

Solution

  • If you are using the free dyno:

    Make a change in the requirements.txt:

    tensorflow-cpu
    

    instead of

    tensorflow
    

    This would reduce your slug size considerably

    Additionally, your issue may also be dependent on model weight size

    Another Tip:

    Use a `.slugignore' file if you are directly pulling the code from GitHub so that you can ignore anything like README to GitHub Actions to notebooks from being added to your Dyno