---
title: "My Journey to a serverless transformers pipeline on Google Cloud"
description: "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."
url: "https://swe.quest/articles/my-journey-to-a-serverless-transformers-pipeline-on-google-cloud-202ccbc112026927"
canonical: "https://huggingface.co/blog/how-to-deploy-a-pipeline-to-google-clouds"
source: "Hugging Face"
published: "2021-03-18"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["serverless","inference","cloud","python","containers"]
---

# My Journey to a serverless transformers pipeline on Google Cloud

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2021-03-18, 8 min read, How-to. Original: [https://huggingface.co/blog/how-to-deploy-a-pipeline-to-google-clouds](https://huggingface.co/blog/how-to-deploy-a-pipeline-to-google-clouds)

## Summary

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.

Written by swe.quest, not by the author.

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

## Topics

- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Containers](https://swe.quest/tags/containers.md) (Infrastructure)

## Prerequisites

- Docker basics ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))
- Python Flask ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- Google Cloud basics ([easy posts on Cloud platforms](https://swe.quest/tags/cloud.md?difficulty=easy))

## Keywords

Hugging Face Transformers, Google Cloud Run, DistilBERT, PyTorch, Flask, gunicorn, App Engine, AI Platform Prediction

## Related posts

- [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.
- [Deploying 🤗 ViT on Vertex AI](https://swe.quest/articles/deploying-vit-on-vertex-ai-1cefa91d85f70e80.md): Hugging Face · 2022-08-19 · Medium · 10 min read · Inference & serving, Cloud platforms, ML platforms, Computer vision, Python
  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.
- [Deploying Speech-to-Speech on Hugging Face](https://swe.quest/articles/deploying-speech-to-speech-on-hugging-face-f49accac75643214.md): Hugging Face · 2024-10-22 · Medium · 10 min read · Inference & serving, Speech & audio, Containers, Real-time systems, Python
  Hugging Face's Speech-to-Speech pipeline (VAD, speech-to-text, LLM, text-to-speech) can be deployed to Inference Endpoints by forking the huggingface-inference-toolkit into a custom Docker image.
- [1 Billion Classifications](https://swe.quest/articles/1-billion-classifications-90168b62de6ffa1b.md): Hugging Face · 2025-02-13 · Medium · 17 min read · Inference & serving, Cost optimization, Performance engineering, Machine learning
  Processing 1B classifications or embeddings on a single-GPU baseline costs about $254 for DistilBERT sentiment classification and $409 for ModernBERT-based gte embeddings on an NVIDIA L4 ($0.8/hr), but roughly $44,500 for ColQwen2 vision embeddings.
- [Rocket Money x Hugging Face: Scaling Volatile ML Models in Production​](https://swe.quest/articles/rocket-money-x-hugging-face-scaling-volatile-ml-models-in-production-acc7e904259d3114.md): Hugging Face · 2023-09-19 · Easy · 8 min read · Inference & serving, ML platforms, Machine learning, Caching, Payments & fintech
  Rocket Money replaced a regex-and-decision-table merchant detector with a BERT-family transformer classifier spanning 4000+ classes, served through Hugging Face's hosted Inference API rather than an in-house MLOps stack.

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)
