将 python 应用程序部署到 Heroku "Slug Size too large"
Deploy python app to Heroku "Slug Size too large"
我正在尝试将用 python 编写的 Streamlit 应用程序部署到 Heroku。我的整个目录是 4.73 MB,其中 4.68 MB 是我的 ML 模型。我的 requirements.txt
看起来像这样:
absl-py==0.9.0
altair==4.0.1
astor==0.8.1
attrs==19.3.0
backcall==0.1.0
base58==2.0.0
bleach==3.1.3
blinker==1.4
boto3==1.12.29
botocore==1.15.29
cachetools==4.0.0
certifi==2019.11.28
chardet==3.0.4
click==7.1.1
colorama==0.4.3
cycler==0.10.0
decorator==4.4.2
defusedxml==0.6.0
docutils==0.15.2
entrypoints==0.3
enum-compat==0.0.3
future==0.18.2
gast==0.2.2
google-auth==1.11.3
google-auth-oauthlib==0.4.1
google-pasta==0.2.0
grpcio==1.27.2
h5py==2.10.0
idna==2.9
importlib-metadata==1.5.2
ipykernel==5.2.0
ipython==7.13.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
jedi==0.16.0
Jinja2==2.11.1
jmespath==0.9.5
joblib==0.14.1
jsonschema==3.2.0
jupyter-client==6.1.1
jupyter-core==4.6.3
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
kiwisolver==1.1.0
Markdown==3.2.1
MarkupSafe==1.1.1
matplotlib==3.2.1
mistune==0.8.4
nbconvert==5.6.1
nbformat==5.0.4
notebook==6.0.3
numpy==1.18.2
oauthlib==3.1.0
opencv-python==4.2.0.32
opt-einsum==3.2.0
pandas==1.0.3
pandocfilters==1.4.2
parso==0.6.2
pathtools==0.1.2
pickleshare==0.7.5
Pillow==7.0.0
prometheus-client==0.7.1
prompt-toolkit==3.0.4
protobuf==3.11.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pydeck==0.3.0b2
Pygments==2.6.1
pyparsing==2.4.6
pyrsistent==0.16.0
python-dateutil==2.8.0
pytz==2019.3
pywinpty==0.5.7
pyzmq==19.0.0
requests==2.23.0
requests-oauthlib==1.3.0
rsa==4.0
s3transfer==0.3.3
scikit-learn==0.22.2.post1
scipy==1.4.1
Send2Trash==1.5.0
six==1.14.0
sklearn==0.0
streamlit==0.56.0
tensorboard==2.1.1
tensorflow==2.1.0
tensorflow-estimator==2.1.0
termcolor==1.1.0
terminado==0.8.3
testpath==0.4.4
toml==0.10.0
toolz==0.10.0
tornado==5.1.1
traitlets==4.3.3
tzlocal==2.0.0
urllib3==1.25.8
validators==0.14.2
watchdog==0.10.2
wcwidth==0.1.9
webencodings==0.5.1
Werkzeug==1.0.0
widgetsnbextension==3.5.1
wincertstore==0.2
wrapt==1.12.1
zipp==3.1.0
当我将我的应用程序推送到 Heroku 时,消息是:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: ! Compiled slug size: 623.5M is too large (max is 500M).
remote: ! See: http://devcenter.heroku.com/articles/slug-size
remote:
remote: ! Push failed
我的 slug 尺寸怎么会太大?是要求的尺寸吗?那么到底如何才能使用 tensorflow 将 python 应用程序部署到 Heroku?
感谢您的帮助!
这意味着下载后您的所有要求加起来高达 600mb,但您只有 500mb 的内存
只需将您的 TensorFlow 版本替换为 2.0.0,方法是:
tensorflow==2.0.0
它有一个更轻的 whl 文件,将适合您的内存限制。
另外,您可以使用 1.7.0 或 1.5.0 版本。
只需使用 tensorflow
版本 1.14
,因为它的大小几乎是 tf2.0+ 的一半,而且服务器的大部分用途。
在我的例子中,在 tf.2.1(280MB)
的地方,slug 的大小几乎从 tf1.14(580MB)
减半
我已经回答了这个here。
原来 Tensorflow 2.0 模块非常大(超过 500MB,Heroku 的限制),因为它支持 GPU。由于 Heroku 不支持 GPU,因此安装支持 GPU 的模块没有意义。
解决方案:
只需在您的要求中将 tensorflow 替换为 tensorflow-cpu。
这对我有用,希望对你也有用!
在 requirements.txt
文件中,我将 tensorflow==2.6.0
替换为 tensorflow-cpu==2.6.0
并且效果很好
我正在尝试将用 python 编写的 Streamlit 应用程序部署到 Heroku。我的整个目录是 4.73 MB,其中 4.68 MB 是我的 ML 模型。我的 requirements.txt
看起来像这样:
absl-py==0.9.0
altair==4.0.1
astor==0.8.1
attrs==19.3.0
backcall==0.1.0
base58==2.0.0
bleach==3.1.3
blinker==1.4
boto3==1.12.29
botocore==1.15.29
cachetools==4.0.0
certifi==2019.11.28
chardet==3.0.4
click==7.1.1
colorama==0.4.3
cycler==0.10.0
decorator==4.4.2
defusedxml==0.6.0
docutils==0.15.2
entrypoints==0.3
enum-compat==0.0.3
future==0.18.2
gast==0.2.2
google-auth==1.11.3
google-auth-oauthlib==0.4.1
google-pasta==0.2.0
grpcio==1.27.2
h5py==2.10.0
idna==2.9
importlib-metadata==1.5.2
ipykernel==5.2.0
ipython==7.13.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
jedi==0.16.0
Jinja2==2.11.1
jmespath==0.9.5
joblib==0.14.1
jsonschema==3.2.0
jupyter-client==6.1.1
jupyter-core==4.6.3
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
kiwisolver==1.1.0
Markdown==3.2.1
MarkupSafe==1.1.1
matplotlib==3.2.1
mistune==0.8.4
nbconvert==5.6.1
nbformat==5.0.4
notebook==6.0.3
numpy==1.18.2
oauthlib==3.1.0
opencv-python==4.2.0.32
opt-einsum==3.2.0
pandas==1.0.3
pandocfilters==1.4.2
parso==0.6.2
pathtools==0.1.2
pickleshare==0.7.5
Pillow==7.0.0
prometheus-client==0.7.1
prompt-toolkit==3.0.4
protobuf==3.11.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pydeck==0.3.0b2
Pygments==2.6.1
pyparsing==2.4.6
pyrsistent==0.16.0
python-dateutil==2.8.0
pytz==2019.3
pywinpty==0.5.7
pyzmq==19.0.0
requests==2.23.0
requests-oauthlib==1.3.0
rsa==4.0
s3transfer==0.3.3
scikit-learn==0.22.2.post1
scipy==1.4.1
Send2Trash==1.5.0
six==1.14.0
sklearn==0.0
streamlit==0.56.0
tensorboard==2.1.1
tensorflow==2.1.0
tensorflow-estimator==2.1.0
termcolor==1.1.0
terminado==0.8.3
testpath==0.4.4
toml==0.10.0
toolz==0.10.0
tornado==5.1.1
traitlets==4.3.3
tzlocal==2.0.0
urllib3==1.25.8
validators==0.14.2
watchdog==0.10.2
wcwidth==0.1.9
webencodings==0.5.1
Werkzeug==1.0.0
widgetsnbextension==3.5.1
wincertstore==0.2
wrapt==1.12.1
zipp==3.1.0
当我将我的应用程序推送到 Heroku 时,消息是:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: ! Compiled slug size: 623.5M is too large (max is 500M).
remote: ! See: http://devcenter.heroku.com/articles/slug-size
remote:
remote: ! Push failed
我的 slug 尺寸怎么会太大?是要求的尺寸吗?那么到底如何才能使用 tensorflow 将 python 应用程序部署到 Heroku? 感谢您的帮助!
这意味着下载后您的所有要求加起来高达 600mb,但您只有 500mb 的内存
只需将您的 TensorFlow 版本替换为 2.0.0,方法是:
tensorflow==2.0.0
它有一个更轻的 whl 文件,将适合您的内存限制。
另外,您可以使用 1.7.0 或 1.5.0 版本。
只需使用 tensorflow
版本 1.14
,因为它的大小几乎是 tf2.0+ 的一半,而且服务器的大部分用途。
在我的例子中,在 tf.2.1(280MB)
tf1.14(580MB)
减半
我已经回答了这个here。
原来 Tensorflow 2.0 模块非常大(超过 500MB,Heroku 的限制),因为它支持 GPU。由于 Heroku 不支持 GPU,因此安装支持 GPU 的模块没有意义。
解决方案:
只需在您的要求中将 tensorflow 替换为 tensorflow-cpu。
这对我有用,希望对你也有用!
在 requirements.txt
文件中,我将 tensorflow==2.6.0
替换为 tensorflow-cpu==2.6.0
并且效果很好