微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

当时我在 Heroku 中部署 django 应用程序时出现“编译的 Slug 大小太大”错误

如何解决当时我在 Heroku 中部署 django 应用程序时出现“编译的 Slug 大小太大”错误

在将我的 django 项目部署到 heroku 时,我遵循了 article 中提到的确切步骤。

但是,git push heroku master 出现以下错误

git push heroku master

请谁能告诉我可能是什么问题。

仅供参考

我的项目根目录中有 procfilerequirements.txtruntime.txt。我也确信我的凭据是正确的。另外,我之前没有推送过任何东西,我是这个应用程序的唯一拥有者。

我的 runtime.txt代码python: 3.7.9

我的 procfile代码web: gunicorn cardamage.wsgi --log-file -

我的requirements.txt

absl-py==0.12.0
astunparse==1.6.3
cachetools==4.2.1
certifi==2020.12.5
chardet==4.0.0
cycler==0.10.0
dj-database-url==0.5.0
Django==1.10
django-heroku==0.3.1
gast==0.3.3
google-auth==1.28.0
google-auth-oauthlib==0.4.4
google-pasta==0.2.0
grpcio==1.36.1
gunicorn==20.1.0
h5py==2.10.0
idna==2.10
importlib-Metadata==3.10.0
joblib==1.0.1
Keras==2.4.0
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
kiwisolver==1.3.1
Markdown==3.3.4
matplotlib==3.4.1
numpy==1.20.2
oauthlib==3.1.0
opt-einsum==3.3.0
pandas==1.1.5
pickle5==0.0.11
Pillow==8.2.0
protobuf==3.15.7
psycopg2==2.8.6
pyasn1==0.4.8
pyasn1-modules==0.2.8
pyparsing==2.4.7
python-dateutil==2.8.1
pytz==2021.1
PyYAML==5.4.1
requests==2.25.1
requests-oauthlib==1.3.0
rsa==4.7.2
scikit-learn==0.24.1
scipy==1.4.1
seaborn==0.11.1
six==1.15.0
tensorboard==2.2.2
tensorboard-plugin-wit==1.8.0
tensorflow==2.2.0
tensorflow-estimator==2.2.0
termcolor==1.1.0
threadpoolctl==2.1.0
typing-extensions==3.7.4.3
urllib3==1.26.4
Werkzeug==1.0.1
whitenoise==5.2.0
wrapt==1.12.1
zipp==3.4.1

解决方法

允许的最大 slug 大小(压缩后)为 heroku 中的 500 MB。您编译的 slug-size 太大了,因为您使用了 { {1}} 模块。

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

Tensorflow

只需将 requirements.py 中的 pip install tensorflow-cpu 替换为 tensorflow

-------------------- 或 --------------------

只需执行以下操作将您的 tensorflow-cpu 版本替换为 2.0.0:

张量流==2.0.0

它的文件重量要轻得多,并且适合您的内存限制。此外,您可以使用 1.7.01.5.0 版本。

更新

您可以尝试通过多种方式减小 slug 大小。最简单的方法是向您的应用程序添加一个 .slugignore 文件,以告诉 slug 编译器忽略您应用程序中任何不必要的文件,例如静态资产。

要确定什么 TensorFlow 在您的 slug 中占用了空间,您可以像这样启动一次性测功机来检查 slug:

files/folders

进入 dyno 后,您可以使用 heroku run bash -a <appname> 命令显示当前目录中的文件和文件夹,按大小排序: 例如

du -ha --max-depth 1 /app | sort -hr

这有助于确定大文件的位置。

您可能还会发现 clearing the build cache 有助于减小 slug 的大小。

在您的情况下,您使用了 ~ $ du -ha --max-depth 1 /app | sort -hr 108M /app 99M /app/vendor 8.1M /app/.heroku 448K /app/lib 292K /app/spec 8.0K /app/Gemfile.lock 4.0K /app/Procfile 4.0K /app/Gemfile tensorflowscikit-learn 等。所有库都非常大。所以 AWS 是您的最佳解决方案。>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?