[英]Install keras tensorflow in AWS ElasticBeanstalk
I created a simple Flask web app with CRUD operations and deployed in beanstalk with the below requirements.txt file我使用 CRUD 操作创建了一个简单的 Flask web 应用程序,并使用以下 requirements.txt 文件部署在 beanstalk 中
Flask==1.1.1
Flask-MySQLdb==0.2.0
Jinja2==2.11.1
mysql==0.0.2
mysqlclient==1.4.6
SQLAlchemy==1.3.15
Werkzeug==1.0.0
Flask-Cors==3.0.8
Flask-Mail==0.9.1
Flask-SocketIO==4.3.0
It worked fine, and then I wrote a below function它工作得很好,然后我在下面写了一个 function
import tensorflow as tf
import keras
from keras.models import load_model
import cv2
import os
def face_shape_model():
classifier = load_model('face_shape_recog_model.h5')
image = cv2.imread('')
res = str(classifier.predict_classes(image, 1, verbose=0)[0])
return {"prediction": res}
with including below packages in to requirments.txt file将以下软件包包含在 request.txt 文件中
keras==2.3.1
tensorflow==1.14.0
opencv-python==4.2.0.32
whole flask application working fine in my local environment so I zipped and deploy into AWS elasticbeanstalk after deployment it logged below error整个 flask 应用程序在我的本地环境中运行良好,所以我在部署后压缩并部署到AWS elasticbeanstalk中,它记录了以下错误
Unsuccessful command execution on instance id(s) 'i-0a2a8a4c5b3e56b81'. Aborting the operation.
Your requirements.txt is invalid. Snapshot your logs for details.
as mentioned above I checked my log and it shows below error如上所述,我检查了我的日志,它显示以下错误
distutils.errors.CompileError: command 'gcc' failed with exit status 1
so I searched about the above error find below solution according to that and I created yml file and added it into .ebextension file as below所以我搜索了上面的错误找到下面的解决方案,我创建了 yml 文件并将其添加到.ebextension文件中,如下所示
packages:
yum:
gcc-c++: []
but I still get the same error.但我仍然得到同样的错误。 how can I solve this or is there any wrong steps above
我该如何解决这个问题或者上面是否有任何错误的步骤
Thank you.谢谢你。
Finally solved with docker container, I created docker environment In AWS ElasticBeanstalk and deployed it, and now it works fine, below shows my config file and Dockerfile最后用 docker 容器解决了,我在 AWS ElasticBeanstalk 中创建了 docker 环境并部署它,现在它工作正常,下面显示了我的配置文件和 Z3254677A7917C6C01F55212F86C57FFFZ
Dockerfile Dockerfile
FROM python:3.6.8
RUN mkdir -p /usr/src/flask_app/
COPY src/requirements.txt /usr/src/flask_app/
WORKDIR /usr/src/flask_app/
RUN pip install -r requirements.txt
COPY . /usr/src/flask_app
ENTRYPOINT ["python", "src/app.py"]
EXPOSE 5000
Dockerrun.aws.json Dockerrun.aws.json
{
"AWSEBDockerrunVersion": "1",
"Ports": [
{
"ContainerPort": "5000",
"HostPort": "80"
}
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.