'Heroku : tensorflow 2.2.1 too large for deployment
im trying to deploy a keras project to heroku but pushing to the repository master branch seems to be problematic for me as the following error is reported every time I try it:
remote: -----> Compressing...
remote: ! Compiled slug size: 836M is too large (max is 500M).
remote: ! See: http://devcenter.heroku.com/articles/slug-size
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to ...
I figured this is due to the tensorflow requirement being way too large for heroku to handle, as git count-objects -vH
reports a more modest size for my project:
count: 1
size: 4.00 KiB
in-pack: 9146
packs: 1
size-pack: 177.42 MiB
prune-packable: 0
garbage: 0
size-garbage: 0 bytes
I have offloaded unneeded files and compressed my repo as much as I could...
The only way for my app to be uploaded is to remove tensorflow from requirements.txt but then my app would not run... The same is true if I downgrade to an earlier version of tensorflow as others have suggested. Is it possible to deploy a project such as this using heroku ?
Solution 1:[1]
Turns out the Tensorflow 2.0 module is very large (more than 500MB, the limit for Heroku) because of its GPU support. Since Heroku doesn't support GPU, it doesn't make sense to install the module with GPU support.
Solution:
Simply replace tensorflow with tensorflow-cpu in your requirements.
This worked for me, hope it works for you too!
Solution 2:[2]
Heroku force slug size limit of 500 MB only when deploying with git + slug compiler, which is the easiest deployment on heroku, and the the most attractive part of the platform. However when you are faced with size limits, you should deploy to Heroku with docker. Heroku offers 3 deployment types. Please check Heroku deployment documentation and a tutorial to deploy dajango to heroku with Docker
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Surya Chereddy |
Solution 2 |