首页 > 解决方案 > Heroku:张量流 2.2.1 太大而无法部署

问题描述

我试图将 keras 项目部署到 heroku 但推送到存储库主分支对我来说似乎有问题,因为每次尝试时都会报告以下错误:

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 ...

我认为这是由于 tensorflow 要求对于 heroku 来说太大而无法处理,因为git count-objects -vH我的项目报告了一个更适中的大小:

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

我已经卸载了不需要的文件并尽可能多地压缩了我的仓库......

上传我的应用程序的唯一方法是从 requirements.txt 中删除 tensorflow,但随后我的应用程序将无法运行......如果我按照其他人的建议降级到早期版本的 tensorflow,情况也是如此。是否可以使用 heroku 部署这样的项目?

标签: tensorflowherokukerasdeploymenttensorflow2.0

解决方案


事实证明,Tensorflow 2.0 模块非常大(超过 500MB,Heroku 的限制),因为它支持 GPU。由于 Heroku 不支持 GPU,因此安装支持 GPU 的模块是没有意义的。

解决方案:

只需在您的要求中将 tensorflow 替换tensorflow -cpu

这对我有用,希望它也对你有用!


推荐阅读