---
title: "Deploying 🤗 ViT on Vertex AI"
description: "A TensorFlow ViT B/16 SavedModel from 🤗 Transformers, with base64 image preprocessing and label postprocessing baked into its signature, can be served on Google Cloud Vertex AI in four SDK steps: upload to the Model Registry, create an Endpoint, deploy with machine/accelerator specs and traffic split, then send prediction requests."
url: "https://swe.quest/articles/deploying-vit-on-vertex-ai-1cefa91d85f70e80"
canonical: "https://huggingface.co/blog/deploy-vertex-ai"
source: "Hugging Face"
published: "2022-08-19"
difficulty: "medium"
kind: "How-to"
reading_minutes: 10
tags: ["inference","cloud","ml-platform","computer-vision","python"]
---

# Deploying 🤗 ViT on Vertex AI

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-08-19, 10 min read, How-to. Original: [https://huggingface.co/blog/deploy-vertex-ai](https://huggingface.co/blog/deploy-vertex-ai)

## Summary

A TensorFlow ViT B/16 SavedModel from 🤗 Transformers, with base64 image preprocessing and label postprocessing baked into its signature, can be served on Google Cloud Vertex AI in four SDK steps: upload to the Model Registry, create an Endpoint, deploy with machine/accelerator specs and traffic split, then send prediction requests. Code covers ModelServiceClient, EndpointServiceClient and PredictionServiceClient usage and the required {"b64": ...} request payload format. A Locust load test on an n1-standard-8 with one T4 GPU averaged 646 ms latency over about 17k requests, and hourly pricing is roughly $0.44 for the machine plus $0.40 for the T4.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)
- [ML platforms](https://swe.quest/tags/ml-platform.md) (AI & ML)
- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- TensorFlow SavedModel
- Google Cloud Platform basics ([easy posts on Cloud platforms](https://swe.quest/tags/cloud.md?difficulty=easy))
- Python ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))

## Keywords

Vertex AI, Vision Transformer, Hugging Face Transformers, TensorFlow Serving, Locust, Google Cloud Storage

## Related posts

- [Deploying 🤗 ViT on Kubernetes with TF Serving](https://swe.quest/articles/deploying-vit-on-kubernetes-with-tf-serving-72269d9df3724559.md): Hugging Face · 2022-08-11 · Medium · 12 min read · Inference & serving, Kubernetes, Containers, Cloud platforms
  A Vision Transformer from Hugging Face Transformers, exported as a TensorFlow SavedModel, is packaged into a custom TensorFlow Serving Docker image and deployed to a GKE cluster.
- [Deploying TensorFlow Vision Models in Hugging Face with TF Serving](https://swe.quest/articles/deploying-tensorflow-vision-models-in-hugging-face-with-tf-serving-a278ea9a908befbd.md): Hugging Face · 2022-07-25 · Medium · 8 min read · Inference & serving, Computer vision, Python, RPC & gRPC
  A Vision Transformer image classifier from Hugging Face Transformers can be served locally with TensorFlow Serving by exporting it as a SavedModel with preprocessing and postprocessing embedded in the graph.
- [My Journey to a serverless transformers pipeline on Google Cloud](https://swe.quest/articles/my-journey-to-a-serverless-transformers-pipeline-on-google-cloud-202ccbc112026927.md): Hugging Face · 2021-03-18 · Medium · 8 min read · Serverless, Inference & serving, Cloud platforms, Python, Containers
  A Hugging Face transformers sentiment-analysis pipeline (DistilBERT fine-tuned on SST-2) was deployed as a low-traffic microservice on Google Cloud Run after AI Platform Prediction (beta instability, checkpoint not a pure TensorFlow model) and App Engine (TensorFlow install failure, PyTorch handling only 2 requests per instance) fell short.
- [Deploy Meta Llama 3.1 405B on Google Cloud Vertex AI](https://swe.quest/articles/deploy-meta-llama-3-1-405b-on-google-cloud-vertex-ai-013efe3f83445849.md): Hugging Face · 2024-08-19 · Medium · 12 min read · Inference & serving, LLMs, Cloud platforms
  Meta Llama 3.1 405B Instruct in FP8 can be served on a single Google Cloud A3 node (8x H100 80GB, ~640 GB VRAM) through Vertex AI, using Hugging Face's Text Generation Inference Deep Learning Container.
- [Why we’re switching to Hugging Face Inference Endpoints, and maybe you should too](https://swe.quest/articles/why-we-re-switching-to-hugging-face-inference-endpoints-and-maybe-you-should-too-bfdcddeceab350fa.md): Hugging Face · 2023-02-15 · Medium · 6 min read · Inference & serving, ML platforms, Cost optimization, Cloud platforms
  A team moved CPU-based transformer inference off a self-built FastAPI + Docker + AWS ECS/Fargate stack onto Hugging Face Inference Endpoints, collapsing deployment to train, push to Hub, deploy.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
