PRA*_*PUT 2 python django heroku spacy
我正在使用 Django 在 Heroku 上部署我的 ML 模型,我需要en_core_web_lg我的应用程序,但无法安装它
我的requirements.txt是这样的:
..
..
djangorestframework==3.12.2
en-core-web-lg==2.3.1
en-core-web-sm==2.3.1
gunicorn==20.0.4
heroku==0.1.4
..
Run Code Online (Sandbox Code Playgroud)
错误是:
ERROR: Could not find a version that satisfies the requirement en-core-web-lg==2.3.1 (from -r /tmp/build_c3075f3c_/requirements.txt (line 14)) (from versions: none)
ERROR: No matching distribution found for en-core-web-lg==2.3.1 (from -r /tmp/build_c3075f3c_/requirements.txt (line 14))
! Push rejected, failed to compile Python app.
! Push failed
Run Code Online (Sandbox Code Playgroud)
您的错误是因为没有名为 的 pip 库en-core-web-lg。请记住,您不能放入en-core-web-lg,requirements.txt因为它不是可以使用 来安装的库pip。它们是 spacy 使用的模型。
接受的答案很好。但是,如果您想要完全自动部署,您也可以在代码中添加如下内容:
try:
nlp = spacy.load("en_core_web_md")
except: # If not present, we download
spacy.cli.download("en_core_web_md")
nlp = spacy.load("en_core_web_md")
Run Code Online (Sandbox Code Playgroud)
如果模型不存在,这将自动下载模型。而且,它不需要您使用 Heroku 终端。仅spacy在requirements.txt文件上是必要的。
最后,请记住,spacy 模型会加载到内存 (RAM) 中。该lg模型(约 700MB)太大,无法安装在 Free、Hobby 或 Standard 1X 测功机(512MB RAM)中。因此它将无法加载,并且测功机将被 R15 杀死(https://devcenter.heroku.com/articles/error-codes#r15-memory-quota-vastly-exceeded)。
有关 dynos 的更多信息: https: //www.heroku.com/dynos
| 归档时间: |
|
| 查看次数: |
3097 次 |
| 最近记录: |