After spending multiple hours, I created this sample model endpoint code I want to host on vertex.ai, these are the three files I have
1. Dockerfile
FROM python:3.7
USER root
ADD . /home/model-server/
WORKDIR /home/model-server/
RUN pip3 install --upgrade pip
RUN pip install -r ./requirements.txt
CMD exec gunicorn -b :5000 --max-requests 1 --graceful-timeout 300 -t 600 main:app
- Main.py -- contains flask app
import json
from flask import Flask, request, Response, jsonify
app = Flask(__name__)
app.config['JSON_SORT_KEYS'] = False
@app.route('/health', methods=['GET'])
def health_check():
return Response(response=json.dumps({"status": 'healthy'}), status=200, mimetype="application/json")
@app.route('/vertex_predict/', methods=['POST'])
def main():
request_json = request.get_json()
request_instances = request_json['instances']
output = {'predictions':
[
{
'result' : "this is working with static output"
}
]
}
return jsonify(output)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
- Requirement.txt
pandas==1.1.1
numpy==1.21.5
flask==2.2.2
gunicorn==20.1.0
this is pretty simple code which we are able to put in artifact registry then
- Import this as model in vertex.ai Model registry
- Then trying to deloy it as endpoint
I tried multiple times but after almost 20 mins, it fails and showing this error all the time
jsonPayload: {
levelname: "ERROR"
logtag: "F"
message: "exec /bin/sh: exec format error"
}
the same flask app is working fine on local machine, not sure what is wrong here on vertex.ai. Can someone please help me here or guide the next steps