MLOps 17: Deployment on Google Cloud
Getting Started with GCP, Understanding The Tools, Deployment on Google Cloud Platform
Google Cloud is another cloud platform that your ML team could be using, and as a Machine Learning Engineer, you may be tasked with doing deployment on this. If your team is not using Google Cloud Platform (GCP), no real reason to read this post.
Table of Contents
Getting Started with GCP
Understanding the Tools
Deployment on Google Cloud Platform
1 - Getting Started with GCP
Google Cloud Platform (GCP) is a suite of cloud computing services that runs on the same infrastructure that Google uses internally for its end-user products. It offers services in computing, storage, networking, big data, machine learning, and the internet of things (IoT), as well as cloud management, security, and developer tools.
1.1 Why Google Cloud?
Data science teams often favor GCP over other platforms like AWS and Azure for several reasons:
Advanced AI and Machine Learning Services: GCP provides cutting-edge AI and ML services, including AutoML and AI Platform, making it easier for data scientists to deploy machine learning models without deep expertise in machine learning algorithms or model tuning.
Data and Analytics Services: With services like BigQuery, a fast, scalable, and fully-managed data warehouse, and Dataflow for stream and batch data processing, GCP excels in handling big data scenarios which are commonplace in data science.
Integration with Google Services: Teams that rely on Google Workspace (formerly G Suite) or other Google services find integration with GCP seamless.
User-Friendly Interface: GCP offers a clean and user-friendly interface, making it accessible for teams with varying levels of cloud expertise.
Compared to the AWS section, you’ll see this one is just straight up far easier
1.2 Setting up a GCP Account
Setting up a GCP account is straightforward. Here's how you can get started:
Sign Up for GCP:
Visit the Google Cloud Platform website.
Click on the “Get started for free” button.
If you have a Google account (such as Gmail), you can use it to sign up. Otherwise, you’ll need to create a new Google account.
Free Trial and Billing:
GCP offers a free trial with $300 credit to explore and use the GCP services.
During the sign-up process, you will be prompted to provide your billing information.
Note: You won’t be charged until you upgrade your account and the free trial credit expires.
Complete the Sign-Up Process:
Follow the on-screen instructions to complete the sign-up process. This will involve agreeing to the terms of service and setting up your billing account.
You will also be asked to select your country and accept the terms of service.
Accessing GCP Console:
Once the account setup is complete, you will be directed to the GCP Console.
The GCP Console is the web-based interface where you can manage your GCP services.
Project Creation:
In GCP, resources are organized into “Projects.”
Create a new project by clicking the “Select a project” dropdown at the top of the console and then “New Project.”
Assign a name to your project and link it to a billing account.
2 - Understanding the Tools
Google Cloud Platform (GCP) offers a suite of tools that are essential in the field of Machine Learning Operations (MLOps). These tools help with building, deploying, and managing ML models. Let's explore some of the key Google Cloud tools used in this process.
2.1 Cloud Source Repositories
Cloud Source Repositories provide fully-featured, scalable, private Git repositories hosted on Google Cloud.
Use Case:
Ideal for collaborative development of any cloud-based application, including ML models.
Integrated with other GCP tools, making it easier to launch builds and deployments directly from the repository.
Supports powerful code browsing and debugging tools.
How to Use:
Create a new repository in the Cloud Source Repositories console.
Clone the repository to your local machine and add your ML project code.
Use it as a standard Git repository, but with the benefits of GCP integration.
2.2 Cloud Build
Cloud Build is a service that executes your builds on Google Cloud Platform. It imports source code, executes build commands, and produces artifacts such as Docker containers or Java archives.
Use Case:
Automating the building, testing, and deployment of ML models stored in your Git repositories.
Integrates with Cloud Source Repositories, GitHub, and Bitbucket.
Useful for creating automated CI/CD pipelines.
How to Use:
Define a
cloudbuild.yaml
file with build steps and configurations.Trigger Cloud Build to automatically build your ML model or application when changes are pushed to your repository.
Example
cloudbuild.yaml
snippet:
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/my-model', '.']
images:
- 'gcr.io/$PROJECT_ID/my-model'
2.3 Container Registry
Container Registry is a single place for your team to manage Docker images, perform vulnerability analysis, and decide who can access what with fine-grained access control.
Use Case:
Storing Docker images of ML models and applications.
Seamlessly integrates with GCP services for deploying applications.
Ensures secure and private storage of container images.
How to Use:
Push your Docker images to Container Registry using Docker CLI or Cloud Build.
Use these images in GCP services like Google Kubernetes Engine, Cloud Run, or Compute Engine.
Set up IAM permissions to control access to the images.
2.4 Google Kubernetes Engine
Google Kubernetes Engine is a managed, production-ready environment for running containerized applications using Kubernetes.
Use Case:
Ideal for deploying, managing, and scaling ML applications using container orchestration.
Provides advanced cluster management features and integrates with GCP for logging, monitoring, and security.
Auto-scaling, auto-upgrading, and auto-repairing features simplify operations.
How to Use:
Create a Kubernetes cluster in the GKE console.
Deploy your containerized ML applications to the cluster.
Manage and scale your deployments using Kubernetes functionalities.
Example command to create a cluster:
gcloud container clusters create my-ml-cluster --num-nodes=3
3 - Deployment on Google Cloud Platform
**The section below is for paid readers**
Keep reading with a 7-day free trial
Subscribe to Data Science & Machine Learning 101 to keep reading this post and get 7 days of free access to the full post archives.