Heroku 一直在安装我之前上传的 Torch 包

问题描述

我正在部署到 heroku,但超出了 500 mb 的 slug 大小。

remote:        Collecting torch>=1.0.0
remote:          Downloading torch-1.7.1-cp36-cp36m-manylinux1_x86_64.whl (776.8 MB)

Torch 以 700mb 的空间继续安装。我在我的requirements.txt 中删除了构建缓存并删除了torch,但slug 继续安装相同的torch 1.7.1

这是我的要求.txt

astroid==2.4.2
atomicwrites==1.4.0
attrs==20.3.0
bert-extractive-summarizer==0.6.1
bert-score==0.3.7
certifi==2020.12.5
click==7.1.2
colorama==0.4.4
Flask==1.1.1
gunicorn==20.0.4
importlib-Metadata==3.4.0
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.11.2
joblib==1.0.0
lazy-object-proxy==1.4.3
markdown==3.3.3
MarkupSafe==1.1.1
mccabe==0.6.1
more-itertools==8.6.0
newspaper3k==0.2.8
nltk==3.5
numpy==1.17.2
packaging==20.8
pandas==1.1.3
pluggy==0.13.1
protobuf==3.14.0
py==1.10.0
pygments==2.7.1
pylint==2.3.1
pyparsing==2.4.7
pytest==4.6.3
regex==2020.11.13
requests==2.25.1
scipy==1.4.1
sentencepiece==0.1.95
six==1.15.0
sumy==0.8.1
transformers==4.2.1
tqdm==4.56.0
typed-ast==1.4.2
typing-extensions==3.7.4.3
waitress==1.4.4
wcwidth==0.2.5
Werkzeug==1.0.1
wincertstore==0.2
wrapt==1.12.1
zipp==3.4.0

解决方法

你还必须在 git 中推送那些更新的 requirements.txt。从 requirements.txt 中删除后,您可以执行以下操作:

git add .
git commit -m "modify requirements.txt"
git push -u origin master

在推送到heroku之后

git push heroku master