使用AppEngine GoogleCloud部署TensorFlow应用程序时出错

2024-04-29 08:42:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经正确部署了python3应用程序构建了一个应用程序:

https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard_python37/building-an-app/building-an-app-1

但现在我已经尝试部署了一个使用神经元网络的应用程序,它在本地使用virtualenv和请求.txt文件:

Flask==1.1.1
numpy==1.17.4
scipy==1.3.2
gensim==3.8.1
tensorflow==2.0.0

“但此应用程序更新后5分钟内使用此服务时出现以下错误]”,默认为“使用此应用程序时出现以下错误]”

^{pr2}$

有人知道问题出在哪里吗?在

在检查构建日志中的错误时,我发现了一行内容:

Step #1 - "builder": exited with error [Errno 12] Cannot allocate memory

所以我变了应用程序yaml收件人:

runtime: python37

handlers:
  # This configures Google App Engine to serve the files in the app's static
  # directory.
- url: /static
  static_dir: static

  # This handler routes all requests not caught above to your main app. It is
  # required when static routes are defined, but can be omitted (along with
  # the entire handlers section) when there are no static files defined.
- url: /.*
  script: auto

resources:
  cpu: 2
  memory_gb: 8
  disk_size_gb: 10

但我还是犯了同样的错误:(

它是构建日志:

ERROR: build step 1 "gcr.io/gae-runtimes/python37_app_builder:python37_20191019_3_7_4_RC00" failed: exit status 1
ERROR
Finished Step #1 - "builder"
Step #1 - "builder": IOError: [Errno 2] No such file or directory: '""/output'
Step #1 - "builder":   File "/usr/local/bin/ftl.par/__main__/ftl/common/ftl_error.py", line 77, in InternalErrorHandler
Step #1 - "builder":   File "/usr/local/bin/ftl.par/__main__.py", line 60, in main
Step #1 - "builder":   File "/usr/local/bin/ftl.par/__main__.py", line 65, in <module>
Step #1 - "builder":     exec code in run_globals
Step #1 - "builder":   File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
Step #1 - "builder":     "__main__", fname, loader, pkg_name)
Step #1 - "builder":   File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
Step #1 - "builder": Traceback (most recent call last):
Step #1 - "builder": tar_runtime_package is likely not on the path
Step #1 - "builder": exited with error [Errno 12] Cannot allocate memory
Step #1 - "builder": ERROR    tar_runtime_package tar -pcf /tmp/tmplWd4v8.tar --hard-dereference --transform flags=r;s,^,/.googleconfig/, --exclude *.pyc .
Step #1 - "builder": INFO     full build took 79 seconds
Step #1 - "builder": INFO     build process for FTL image took 79 seconds
Step #1 - "builder": INFO     Building app layer took 0 seconds
Step #1 - "builder": INFO     tar_runtime_package took 0 seconds
Step #1 - "builder": INFO     tar_runtime_package tar -pcf /tmp/tmplWd4v8.tar --hard-dereference --transform flags=r;s,^,/.googleconfig/, --exclude *.pyc .
Step #1 - "builder": INFO     starting: tar_runtime_package
Step #1 - "builder": INFO     starting: Building app layer
Step #1 - "builder": INFO     Building app layer took 76 seconds
Step #1 - "builder": INFO     Finished gzipping tarfile.
Step #1 - "builder": INFO     gzip_tar_runtime_package took 58 seconds
Step #1 - "builder": 
Step #1 - "builder": INFO     `gzip_tar_runtime_package` stdout:
Step #1 - "builder": INFO     gzip_tar_runtime_package gzip /tmp/tmpStZGpR.tar -1
Step #1 - "builder": INFO     starting: gzip_tar_runtime_package
Step #1 - "builder": INFO     tar_runtime_package took 8 seconds
Step #1 - "builder": 
Step #1 - "builder": INFO     `tar_runtime_package` stdout:
Step #1 - "builder": INFO     tar_runtime_package tar -pcf /tmp/tmpStZGpR.tar --hard-dereference --transform flags=r;s,^,/srv/, --exclude *.pyc .
Step #1 - "builder": INFO     starting: tar_runtime_package
Step #1 - "builder": INFO     starting: Building app layer
Step #1 - "builder": INFO     checking_cached_requirements.txt_layer took 1 seconds
Step #1 - "builder": INFO     [CACHE][HIT] v0.17.0:PYTHON (requirements)->62b99263456c1af3bff1307a585449789858bb17c695a2accfa55a3e5ee8f950
Step #1 - "builder": INFO     check python version took 0 seconds
Step #1 - "builder": 
Step #1 - "builder": INFO     `python version` stderr:
Step #1 - "builder": /opt/python3.7/bin/python3.7 --version
Step #1 - "builder": INFO     `python version` full cmd:
Step #1 - "builder": INFO     starting: check python version
Step #1 - "builder": 
Step #1 - "builder": gunicorn
Step #1 - "builder": tensorflow==2.0.0
Step #1 - "builder": gensim==3.8.1
Step #1 - "builder": scipy==1.3.2
Step #1 - "builder": numpy==1.17.4
Step #1 - "builder": Flask==1.1.1
Step #1 - "builder": INFO     new_descriptor_contents: 
Step #1 - "builder": 
Step #1 - "builder": gunicorn
Step #1 - "builder": tensorflow==2.0.0
Step #1 - "builder": gensim==3.8.1
Step #1 - "builder": scipy==1.3.2
Step #1 - "builder": numpy==1.17.4
Step #1 - "builder": Flask==1.1.1
Step #1 - "builder": INFO     descriptor_contents:
Step #1 - "builder": INFO     {"architecture": "amd64", "author": "Unknown", "config": {}, "created": "2019-12-02T22:00:00Z", "history": [{"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Unknown", "created": "2019-12-02T22:00:00Z", "created_by": "//containerregistry/client:ftl.par"}, {"author": "Bazel", "created": "1970-01-01T00:00:00Z", "created_by": "bazel build ..."}], "os": "linux", "rootfs": {"diff_ids":

谢谢!在


Tags: infoclientapppackagebystepbuildertar
2条回答

谢谢你的反馈,我终于成功了。我不得不改变应用程序yaml要手动缩放和env flex:

runtime: python37
env: flex

manual_scaling:
  instances: 1

resources:
  cpu: 2
  memory_gb: 8
  disk_size_gb: 10

我必须创建一个docker映像,并将其推送到存储库,然后使用该映像进行部署。它是Dockerfile:

^{pr2}$

这就是跑步_服务器.sh我使用的:

#!/bin/bash
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
python3 -u /main.py

然后您必须遵循以下步骤:

Generation Docker Image: docker build . -t [IMAGE]

Tag Local Docker Image: docker tag [IMAGE] eu.gcr.io/[PROJECT-ID]/[IMAGE]

Push Docker Image: docker push eu.gcr.io/[PROJECT-ID]/[IMAGE]

Deploy App: gcloud app deploy  image-url=eu.gcr.io/[PROJECT-ID]/[IMAGE]

它现在工作得很好:)

您遇到的错误似乎是指出您使用的GAE实例内存不足。在

作为一种选择,您可能希望尝试将实例的class更改为具有更高内存限制的实例。但是,请记住,它也会影响pricing。在

相关问题 更多 >