Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?


2 Answers

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!

like image 124
Surya Chereddy Avatar answered Oct 26 '22 09:10

Surya Chereddy


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

like image 2
Muhammad Annaqeeb Avatar answered Oct 26 '22 07:10

Muhammad Annaqeeb