Skip to content

SOP-004: Model Deployment

DOCUMENT CONTROL

FieldValue
SOP IDSOP-004
Version1.0
StatusActive

INFO

Document Control Title: Model Deployment to Vertex AI Version: 1.0 Last Updated: 2023-04-10 Author: [Your Name]

Purpose

This Standard Operating Procedure (SOP) document outlines the steps to deploy a trained machine learning model to the Vertex AI platform. Vertex AI is a fully-managed platform for building and deploying machine learning models at scale.

Procedure Flowchart

ascii
┌────────────────────────┐
│ Start Model Deployment │
└────────────────────────┘

┌────────────────────────┐
│ Package Model Artifacts │
└────────────────────────┘

┌────────────────────────┐
│ Create Vertex AI Model │
└────────────────────────┘

┌────────────────────────┐
│ Create Vertex AI Endpoint│
└────────────────────────┘

┌────────────────────────┐
│     Test Endpoint      │
└────────────────────────┘

┌────────────────────────┐
│       Deployment       │
└────────────────────────┘

┌────────────────────────┐
│        End SOP         │
└────────────────────────┘

Step-by-Step Procedure

WARNING

Before starting, ensure you have the necessary permissions and access to the Vertex AI platform in your Google Cloud project.

1. Package Model Artifacts

  1. Gather the necessary model artifacts, which may include the trained model file, model configuration, and any other supporting files.
  2. Package the model artifacts into a compressed file (e.g., a .zip or .tar.gz file).
  3. Upload the packaged model artifacts to a storage location, such as a Google Cloud Storage bucket, that is accessible to the Vertex AI platform.

Example:

bash
# Assuming the model artifacts are in the "model" directory
zip -r model.zip model/
gsutil cp model.zip gs://your-bucket/path/to/model.zip

2. Create Vertex AI Model

  1. Navigate to the Vertex AI section of the Google Cloud Console.
  2. Click on "Models" in the left-hand menu.
  3. Click on the "Create Model" button.
  4. Provide a name for your model and select the appropriate region.
  5. In the "Model artifacts" section, specify the location of the packaged model artifacts you uploaded in the previous step.
  6. Configure any other model-specific settings, such as the model format and the serving container image.
  7. Click "Create" to start the model creation process.

INFO

Refer to the Vertex AI documentation for more details on model creation: https://cloud.google.com/vertex-ai/docs/start/create-model

3. Create Vertex AI Endpoint

  1. Once the model creation is complete, navigate to the "Endpoints" section in the Vertex AI console.
  2. Click on the "Create Endpoint" button.
  3. Provide a name for your endpoint and select the appropriate region.
  4. In the "Model" section, select the model you created in the previous step.
  5. Configure any other endpoint-specific settings, such as scaling options and monitoring.
  6. Click "Create" to start the endpoint creation process.

INFO

Refer to the Vertex AI documentation for more details on endpoint creation: https://cloud.google.com/vertex-ai/docs/start/create-endpoint

4. Test Endpoint

  1. Once the endpoint creation is complete, you can test the deployed model by sending sample requests to the endpoint.
  2. Refer to the Vertex AI documentation for sample code and instructions on how to send test requests to the endpoint.

Example:

python
import os
from google.cloud import aiplatform

# Set your project ID and endpoint name
project_id = 'your-project-id'
endpoint_name = 'your-endpoint-name'

# Initialize the Vertex AI client
aiplatform.init(project=project_id, location='us-central1')

# Create a sample input for your model
sample_input = {'your-input-key': 'your-input-value'}

# Send a prediction request to the endpoint
response = aiplatform.Endpoint(endpoint_name).predict(instances=[sample_input])

print(response)

INFO

Refer to the Vertex AI documentation for more details on testing endpoints: https://cloud.google.com/vertex-ai/docs/predictions/online-predictions

5. Deploy Model

  1. If the model testing is successful, you can proceed with the final deployment step.
  2. In the Vertex AI console, navigate to the "Endpoints" section and locate the endpoint you created.
  3. Click on the "Deploy" button to start the deployment process.
  4. Configure any deployment-specific settings, such as the number of replicas and scaling options.
  5. Click "Deploy" to initiate the deployment.

INFO

Refer to the Vertex AI documentation for more details on model deployment: https://cloud.google.com/vertex-ai/docs/start/deploy-model

Verification Checklist

  • [ ] Model artifacts are packaged and uploaded to a storage location.
  • [ ] Vertex AI model is created with the correct model artifacts.
  • [ ] Vertex AI endpoint is created and configured correctly.
  • [ ] Endpoint test requests are successful.
  • [ ] Model deployment is completed without any errors.

Troubleshooting

IssuePossible CausesResolution
Model creation fails- Incorrect model artifacts
- Unsupported model format
- Insufficient permissions
- Verify the model artifacts and their format
- Check the model requirements in the Vertex AI documentation
- Ensure you have the necessary permissions to create a model
Endpoint creation fails- Incorrect model selection
- Unsupported endpoint configuration
- Insufficient permissions
- Verify the model selection and endpoint configuration
- Check the endpoint requirements in the Vertex AI documentation
- Ensure you have the necessary permissions to create an endpoint
Test requests fail- Incorrect input data format
- Endpoint not deployed correctly
- Insufficient permissions
- Verify the input data format matches the model requirements
- Check the endpoint deployment status and configuration
- Ensure you have the necessary permissions to send test requests
Deployment fails- Incorrect deployment configuration
- Resource constraints
- Insufficient permissions
- Verify the deployment configuration and settings
- Check for resource constraints in the selected region
- Ensure you have the necessary permissions to deploy the model

See Also