Reputation: 77
I have a FastAPI API that takes an image, loads a Tensorflow model, and returns a prediction. Locally everything is working fine, but I want to host it on Google Cloud I followed a tutorial and did the following:
runtime: python39
entrypoint: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
fastapi
numpy
Pillow
pydantic
tensorflow
uvicorn
gunicorn
opencv-python
After that, I uploaded everything on Github, opened Google cloud, created a new project, activated cloud run and cloud build, cloned the git repo, and ran
gcloud app deploy app.yaml
I installed the requirements with
pip3 install -r requirements.txt
and finally launched the API using
gcloud app browse
What I get is either
upstream connect error or disconnect/reset before headers. reset reason: connection termination" or "Error: Server Error
or
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
Upvotes: 1
Views: 1030
Reputation: 801
As stated by Isabi, this was generated because the instance ran out of memory. Have you tried increasing the instance memory? Try changing the instance class in your app.yaml, 2, this will increase the memory limit according to the assigned class.
You can also use this stack answer to increase the instance memory
Upvotes: 1