在部署期间安装requirements.txt时出现Gcloud flask应用程序错误

问题描述 投票:0回答:1

我正在尝试在使用pytorch的gcloud上部署一个烧瓶应用程序。当我在本地运行服务器它工作正常。但是当我使用gcloud app deploy部署相同的代码时,会出现以下错误。

Step #1: Step 6/9 : ADD requirements.txt /app/
Step #1:  ---> eed90d6f59c6
Step #1: Step 7/9 : RUN pip install -r requirements.txt
Step #1:  ---> Running in e6f627cd6ee4
Step #1: Collecting torch (from -r requirements.txt (line 1))
Step #1:   Downloading 
https://files.pythonhosted.org/packages/df/a4/7f5ec6e9df1bf13
f1881353702aa9713fcd997481b26018f35e0be85faf7/torch-0.4.0-cp27-cp27mu-
manylinux1_x8
6_64.whl (484.0MB)
Step #1: Exception:
Step #1: Traceback (most recent call last):
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/basecommand.py", line 215, in main
Step #1:     status = self.run(options, args)
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/commands/install.py", line 335, in run
Step #1:     wb.build(autobuilding=True)
Step #1:   File "/env/local/lib/python2.7/site-packages/pip/wheel.py", 
line 749, in build
Step #1:     self.requirement_set.prepare_files(self.finder)
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/req/req_set.py", line 380, in prepare_files
Step #1:     ignore_dependencies=self.ignore_dependencies))
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/req/req_set.py", line 620, in _prepare_file
Step #1:     session=self.session, hashes=hashes)
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/download.py", line 821, in unpack_url
Step #1:     hashes=hashes
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/download.py", line 659, in unpack_http_url
Step #1:     hashes)
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/download.py", line 882, in _download_http_url
Step #1:     _download_url(resp, link, content_file, hashes)
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/download.py", line 603, in _download_url
Step #1:     hashes.check_against_chunks(downloaded_chunks)
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/utils/hashes.py", line 46, in check_against_chunks
Step #1:     for chunk in chunks:
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/download.py", line 571, in written_chunks
Step #1:     for chunk in chunks:
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/utils/ui.py", line 139, in iter
Step #1:     for x in it:
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/download.py", line 560, in resp_read
Step #1:     decode_content=False):
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/_vendor/urllib3/response.py", line 436, in stream
Step #1:     data = self.read(amt=amt, decode_content=decode_content)
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/_vendor/urllib3/response.py", line 384, in read
Step #1:     data = self._fp.read(amt)
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/_vendor/cachecontrol/filewrapper.py", line 63, in read
Step #1:     self._close()
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/_vendor/cachecontrol/filewrapper.py", line 50, in _close
Step #1:     self.__callback(self.__buf.getvalue())
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/_vendor/cachecontrol/controller.py", line 275, in 
cache_response
Step #1:     self.serializer.dumps(request, response, body=body),
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/_vendor/cachecontrol/serialize.py", line 55, in dumps
Step #1:     "body": _b64_encode_bytes(body),
Step #1:   File "/env/local/lib/python2.7/site-
packages/pip/_vendor/cachecontrol/serialize.py", line 12, in 
_b64_encode_bytes
Step #1:     return base64.b64encode(b).decode("ascii")
Step #1: MemoryError 
Step #1: You are using pip version 9.0.3, however version 10.0.1 is 
available.
Step #1: You should consider upgrading via the 'pip install --upgrade 
pip' command.
Step #1: The command '/bin/sh -c pip install -r requirements.txt'  
returned a non-zero code: 2
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/cloud-

builders/docker@sha256:5836cd0f940f2f1a912b8fee4c74e5
f1a84df92aab557c608a94e171e9df8d46" failed: exit status 2
Step #1: 
----------------------------------------------------------------------
----------------------------------------------------------------------
---------------------------

ERROR: (gcloud.app.deploy) Cloud build failed. Check logs at 
https://console.cloud.google.com/gcr/builds/d1e646e5-53f4-43d0-8504-
98226e97de78?project=1091101138750 Fai
lure status: UNKNOWN: Error Response: [2] Build failed; check build 
logs 
for details

我的requirements.txt看起来像这样

火炬

torchvision

jsonpickle

瓶== 0.12.2

gunicorn == 19.7.1

numpy的

matplotlib

和app.yaml看起来像这样。

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app
runtime_config:
  python_version: 2
# This sample incurs costs to run on the App Engine flexible 
environment.
# The settings below are to reduce costs during testing and are not 
appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/python/configuring-
your-app-with-app-yaml
manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 1.5
  disk_size_gb: 10
google-app-engine docker flask deep-learning pytorch
1个回答
0
投票

通过使用您提供的相同app.yaml和requirements.txt片段,我能够重现您获得的错误。

我尝试将app.yaml文件中的python_version值更改为3而不是2,并且部署工作正常。

因此,如果Python 3适合您而不影响项目中的其他库,那么这可能是一个解决方案。

我还尝试删除requirements.txt文件中的torch和torchvision行,并将Python版本保持为2.该配置已成功部署。

问题似乎是Pytorch和App Engine上的Python 2之间的兼容性问题。我建议检查Pytorch forums,看看是否有其他人有类似的问题。

© www.soinside.com 2019 - 2024. All rights reserved.