Google Cloud Function/Python 3.7/requirements.txt 使部署失败 [英] Google Cloud Function / Python 3.7 / requirements.txt makes deploy fail

查看:16
本文介绍了Google Cloud Function/Python 3.7/requirements.txt 使部署失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过 requirements.txt 部署具有依赖项的谷歌云功能.部署需要很长时间并失败并显示以下消息:

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"}]}

我发现,requirements.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有关,上面的网址指向的是没有cuda的torch版本.

The problems seems to be related to cuda, the URL above points to the torch version without cuda.

推荐答案

PyTorch 在 PyPI 上发布了一个默认支持 CUDA/Nvidia GPU 的发行版,但 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
  • 包装:Pip
  • 语言: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 使部署失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆