【发布时间】:2020-09-28 08:40:09
【问题描述】:
我想将带有 gunicorn 和 tensorflow 服务的 Flask API 部署到 Google App Engine (Flex)。我写了一个 Dockerfile 和 startup.sh 但未能部署。我将内存增加到 6GB 并将 gunicorn 的超时设置为 2 分钟,但这没有帮助。
Dockerfile 运行成功,但 startup.sh 没有同时启动 gunicorn 和 tensorflow 服务。谁能指出 sartup.sh 有什么问题?
Dockerfile
FROM gcr.io/google-appengine/python
RUN virtualenv /env -p python3.7
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
RUN apt-get update
ADD app/ /app/
RUN pip install --upgrade pip
RUN pip install -r /app/requirements.txt
RUN echo "deb http://storage.googleapis.com/tensorflow-serving-apt stable tensorflow-model-server tensorflow-model-server-universal" | tee /etc/apt/sources.list.d/tensorflow-serving.list && \
curl https://storage.googleapis.com/tensorflow-serving-apt/tensorflow-serving.release.pub.gpg | apt-key add -
RUN apt-get update
RUN apt-get install -y tensorflow-model-server
RUN apt-get install -y nginx
COPY app/default /etc/nginx/sites-available/default
WORKDIR /root
RUN chmod -R a+r /var/www/html
COPY startup.sh /startup.sh
RUN chmod 744 /startup.sh
RUN cd /
CMD /startup.sh
startup.sh
#!/bin/bash
/etc/init.d/nginx start
cd /app && nohup gunicorn app:app --bind 127.0.0.1:8081 --workers 1 --timeout 120 &
nohup tensorflow_model_server \
--rest_api_port=8501 \
--model_name=bird_net \
--model_base_path=/app/saved_model &
标准错误输出
$ gcloud app deploy
...
(ommited)
...
bc9f3e1065bb: Pushed
latest: digest: sha256:8dd67b5292199744a51d58c3cafb5ff17b87c4b39e35589c0d44e646dc1dd272 size: 5567
DONE
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error! Code: APP_CONTAINER_CRASHED
* Starting nginx nginx
...done.
【问题讨论】:
-
在 Stack Overflow 上,您必须指出哪里出了问题或不起作用,我们会尽力提供帮助。那么,真正的问题是什么?
-
你是对的。我补充说。我不知道如何运行两个进程,gunicorn 和 tensroflow 服务。我让他们通过 nohup ... & 进入后台进程,但 gunicorn 似乎没有启动。当在前台启动时,gunicorn 启动良好。 TensorFlow 服务也是如此。
标签: python docker google-app-engine gunicorn tensorflow-serving