Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 10 min read How-to mediumAdept

Deploying πŸ€— ViT on Vertex AI

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.

Assumes: TensorFlow SavedModelGoogle Cloud Platform basicsPython

Related posts

  • Deploying πŸ€— ViT on Kubernetes with TF Serving

    Hugging Face mediumAdept

    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. The walkthrough covers building the image via docker commit with the versioned model directory layout, pushing it to GCR, and writing Deployment, Service (LoadBalancer exposing gRPC 8500 and REST 8501) and HorizontalPodAutoscaler manifests applied with kubectl or Kustomize. It also explains how CPU requests drive HPA scaling decisions and how to tune TF Serving's inter-op and intra-op parallelism flags.

  • Deploying TensorFlow Vision Models in Hugging Face with TF Serving

    Hugging Face mediumAdept

    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. A custom serving signature accepts base64-encoded JPEG strings, then decodes, resizes, normalizes and transposes them to channel-first, and returns a class label plus softmax confidence. Building these steps into the model cuts request payload size and avoids training-serving skew. The walkthrough covers launching tensorflow_model_server and querying both the REST endpoint (port 8501) and the gRPC endpoint (port 8500), including how to select a model version.

  • My Journey to a serverless transformers pipeline on Google Cloud

    Hugging Face mediumAdept

    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. The final setup is a Flask app served by gunicorn with one worker and one thread in a Docker image, with Cloud Run memory raised to 4 GB because the model needs most of it. Requests take under five seconds including model loading, plus roughly 10 seconds on cold start; loading the model at startup instead of per request would cut both latency and memory. The image is about 1 GB (PyTorch ~700 MB, model ~250 MB), so storage costs roughly €0.10 per GB per month on top of request costs.

  • Deploy Meta Llama 3.1 405B on Google Cloud Vertex AI

    Hugging Face mediumAdept

    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. FP16 weights would need ~810 GB, so FP8 (~405 GB) is the recommended way to fit one node while leaving room for KV cache and CUDA graphs. The walkthrough covers the A3 quota requests, gcloud and SDK setup, registering the model with TGI environment variables (MODEL_ID, NUM_SHARD=8, HF token), and deploying to an endpoint, which takes about 25-30 minutes. It then shows how to apply the Llama 3.1 chat template with transformers and send prediction requests to the endpoint from Python.

  • Why we’re switching to Hugging Face Inference Endpoints, and maybe you should too

    Hugging Face mediumAdept

    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. In ab benchmarks with a RoBERTa text classifier, a 4-vCPU endpoint answered in 80Β±30 ms versus ~200 ms on their ECS container, and an 8-vCPU endpoint in 43 ms. Cost runs 24–50% higher than Fargate (about $60/month more for a large instance), which they judge worth it without a dedicated MLOps team, though not at hundreds of services. The main gap they note is the lack of a Terraform provider; they deploy with their own hugie CLI.

The quest for software engineering knowledge.

Look:
Layout: