问题描述
我尝试通过requirements.txt部署具有依赖项的Google云功能.部署耗时非常长,并且失败,并显示以下消息:
I try to deploy a google cloud function with dependencies via requirements.txt. Deployment takes terribly long and fails with this message:
(gcloud.functions.deploy) OperationError: code=3, message=Build failed: {"cacheStats": [{"status": "MISS", "hash": "ebbabef833cbc5bf98d2562c9f28bd5ab91e1a867134bb0c08f84397510ff774", "type": "docker_layer_cache", "level": "global"}, {"status": "MISS", "hash": "ebbabef833cbc5bf98d2562c9f28bd5ab91e1a867134bb0c08f84397510ff774", "type": "docker_layer_cache", "level": "project"}]}
我发现,requests.txt似乎是问题所在,当我仅通过Web控制台(带有HelloWorld示例)创建python3.7云函数并将需求粘贴到那里时,我会得到相同的行为. requirements.txt如下:
I figured out, that the requirements.txt seems to be the problem, I get the same behaviour when I just create a python3.7 cloud function over web console (with the HelloWorld Example) and paste requirements there. requirements.txt looks like:
Flask==1.0.2
dill>=0.2.8
numpy>=1.15.0
requests>=2.20.0
six==1.12.0
spacy>=2.1.0
torch>=1.0.0
torchtext>=0.3.1
我还有几个其他的使用requirements.txt的示例,但是我在这里看不到重点.而且我不知道是否有办法进一步调试它.
I have several other examples working with requirements.txt, but I don't see the point here. And I don't know if there is a way to further debug this.
有想法吗?
似乎pytorch引起了问题,它可以通过直接指向whl文件的URL来工作,例如
It seems that pytorch is causing the problem, it works by directly pointing to the URL of the whl file like
...
spacy>=2.1.0
https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp37-cp37m-linux_x86_64.whl
torchtext>=0.3.1
问题似乎与cuda有关,上面的URL指向没有cuda的火炬版本.
The problems seems to be related to cuda, the URL above points to the torch version without cuda.
推荐答案
PyTorch默认在CUDA/Nvidia GPU支持下在PyPI上发布发行版,但是Cloud Functions运行时不支持GPU或必需的系统库.
PyTorch ships a distribution on PyPI with CUDA/Nvidia GPU support by default, but the Cloud Functions runtime doesn't have GPU support, or the necessary system libraries.
相反,在选择以下内容时,您应该使用 https://pytorch.org/提供的URL.
Instead, you should use the URL provided by https://pytorch.org/ when selecting:
- 您的操作系统:Linux
- 包装:点子
- 语言:Python 3.7
- CUDA:无
pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp37-cp37m-linux_x86_64.whl
哪个会成为您的requirements.txt
:
Flask==1.0.2
dill>=0.2.8
numpy>=1.15.0
requests>=2.20.0
six==1.12.0
spacy>=2.1.0
https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp37-cp37m-linux_x86_64.whl
torchtext>=0.3.1
这篇关于Google Cloud Function/Python 3.7/requirements.txt使部署失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!