Deploying Machine Learning Models in GCP

Server-based deployment

Serverless deployment

CV Model to be deployed


Google Compute Engine

Google Compute Engine — GCE
  1. Create a GCE instance with appropriate CPU and Memory based on the application’s requirement. For our application, we use an e2-medium instance that has two vCPUs and four GB of memory with an Ubuntu OS. Also, make sure that you have checked the Allow HTTP Traffic in the firewall setting while creating the instance. Deciding on the appropriate type of instance is mainly experimental and driven by profiling analysis.
sudo docker build -t mxnet:v1 .
sudo docker run -d --rm -p 8080:8080 mxnet:v1 /bin/bash -c “gunicorn --bind :8080 --workers 1 --threads 8 main:app”

Google Kubernetes Engine

Google Kubernetes Engine — GKE
docker build -t<PROJECT_ID>/object-detection-gke:v1 .
gcloud config set project <PROJECT-ID>
gcloud auth configure-docker
gcloud services enable
docker push<PROJECT_ID>/object-detection-gke:v1
partha@cloudshell:~ (medium-article-323805)$ kubectl get nodes
gke-cluster-1-default-pool-122dcf3d-gk37 Ready <none> 13d v1.20.8-gke.900
gke-cluster-1-default-pool-122dcf3d-mv6x Ready <none> 13d v1.20.8-gke.900
kubectl create -f <path_to_deployment.yaml_file>
A snippet from GKE Console

Google Cloud Run

Google Cloud Run
  1. Navigate to Cloud Run in the Google Console and select Create Service
Google Cloud Function Console

Google App Engine

Google App Engine
gcloud app deploy

Key Takeaway



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Parthasarathy Subburaj

Parthasarathy Subburaj

Helping computers see and understand the world as we do!