Run Hugging Face transformers on GPU enabled Cloud Run functions

Google Cloud Tech · Intermediate ·🧠 Large Language Models ·1y ago

Key Takeaways

Deploys Hugging Face transformers on GPU enabled Cloud Run functions

Full Transcript

we create a GPU enabled Cloud run function that will directly host a Jamma 2 2B model downloaded from the huging face website I'll also show you how easy it is to leverage huging face Transformers python library to rapidly build AI powered applications with Cloud run let's get started first first I'll create a cloud run function via the UI let's go ahead give the service a name and we're going to choose python as our runtime let's go ahead make the public uh endpoint public for the demo purpose and choose the CPU always allocated under the containers tab I'm going to go ahead configure the memory and CPU required for this container instance and we attach an Nvidia L4 to this to this let's go ahead and set concurrency to be one all right next let's go to take a look at the Vari variables tab here I'm setting up two environment variables the first one uh it will be a LD Li Library pass that's going to point to the pass to for me to access to the Cuda drivers next environment variable I'm using the secret manager to store my huging phas token which is needed later on for me to download the models from the huggingface website let's go ahead and create this Cloud run function now it's going to take a few second all right so the cloud run function service is created let's Jump Jump Right In to edit our code first let's put in some of the requirements needed for this app and then for the main logic of this application instead of writing any new codes let's go ahead go to the huging face website here we're going to copy the code over into our functions event handler all right so let's copy the code here let's go ahead fix the indentation and then we'll move the inputs to the top of the file let's update the device wise map to Cuda so here I uh we are leveraging the Transformers python library to interact with the Jamma model and then I'm asking JMA to help me write a poem about machine learning and also know the maximum output token here is set to 32 so expect the poem from the Jamma model be truncated all right so so far most of the code is based on the existing samples except we made a few tricks here and there and we didn't even need to write any new code everything looks good let's go ahead and save and deploy This Cloud run function in the interest of time uh let's go ahead and switch to this pre-deployed pre-build Cloud run function here you can see the source code is identical to the one we just deployed now let's go ahead actually invoke this Endo since this is a warm instance the Jamma model responds quite quickly as expected poem is truncated because of the token setting in the sample code all right so we've done it we have successfully demonstrated the Jamma model running on a GPU enabled Cloud run function

Original Description

See how to create a GPU enabled Cloud Run function that directly hosts a Gemma 2 2B model. Learn how easy it is to leverage the Hugging Face Transformer Improvement library to rapidly build AI powered applications with Cloud Run. Watch more Cloud Run Demo Series → https://goo.gle/CloudRunDemos Subscribe to Google Cloud Tech → https://goo.gle/GoogleCloudTech #CloudRun #GoogleCloud #GPU #AI #HuggingFace
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Google Cloud Tech · Google Cloud Tech · 0 of 60

← Previous Next →
1 I’m going for it #GoogleCloudCertified
I’m going for it #GoogleCloudCertified
Google Cloud Tech
2 I had to get #GoogleCloudCertified
I had to get #GoogleCloudCertified
Google Cloud Tech
3 Be better overall at what you do #GoogleCloudCertified
Be better overall at what you do #GoogleCloudCertified
Google Cloud Tech
4 Cloud Monitoring on our radar #Analysis #Uptime
Cloud Monitoring on our radar #Analysis #Uptime
Google Cloud Tech
5 Introduction to Generative AI Studio
Introduction to Generative AI Studio
Google Cloud Tech
6 How to use Github Actions with Google's Workload Identity Federation
How to use Github Actions with Google's Workload Identity Federation
Google Cloud Tech
7 Introduction to Responsible AI
Introduction to Responsible AI
Google Cloud Tech
8 Networking updates and CDMC-certified architecture
Networking updates and CDMC-certified architecture
Google Cloud Tech
9 Create and use a Cloud Storage bucket
Create and use a Cloud Storage bucket
Google Cloud Tech
10 How to digitize text from documents
How to digitize text from documents
Google Cloud Tech
11 Faster analytical queries with AlloyDB
Faster analytical queries with AlloyDB
Google Cloud Tech
12 Next ‘23 sessions and FaaS Wave
Next ‘23 sessions and FaaS Wave
Google Cloud Tech
13 Introduction to Assured Open Source Software
Introduction to Assured Open Source Software
Google Cloud Tech
14 BigQuery Cost Optimization: Storage
BigQuery Cost Optimization: Storage
Google Cloud Tech
15 BigQuery Cost Optimization: Compute
BigQuery Cost Optimization: Compute
Google Cloud Tech
16 BigQuery Cost Optimization: Select Queries
BigQuery Cost Optimization: Select Queries
Google Cloud Tech
17 Remote Field Equipment Management with Manufacturing Data Engine
Remote Field Equipment Management with Manufacturing Data Engine
Google Cloud Tech
18 Supercharging your applications with Cloud SQL Enterprise Plus
Supercharging your applications with Cloud SQL Enterprise Plus
Google Cloud Tech
19 Vector Support on our radar #GenAI
Vector Support on our radar #GenAI
Google Cloud Tech
20 Architecting a blockchain startup with Google Cloud
Architecting a blockchain startup with Google Cloud
Google Cloud Tech
21 Kubernetes and multitasking updates!
Kubernetes and multitasking updates!
Google Cloud Tech
22 GKE: Using Kubernetes Events
GKE: Using Kubernetes Events
Google Cloud Tech
23 How to configure firewall rules for Cloud Composer
How to configure firewall rules for Cloud Composer
Google Cloud Tech
24 Vertex AI Embeddings API + Matching Engine: Grounding LLMs made easy
Vertex AI Embeddings API + Matching Engine: Grounding LLMs made easy
Google Cloud Tech
25 Geospatial analytics on our radar #EarthEngine #BigQuery
Geospatial analytics on our radar #EarthEngine #BigQuery
Google Cloud Tech
26 Ensuring requests are set in Kubernetes
Ensuring requests are set in Kubernetes
Google Cloud Tech
27 Cloud Next 2023, Google research program, and more!
Cloud Next 2023, Google research program, and more!
Google Cloud Tech
28 How to migrate projects between organizations with Resource Manager
How to migrate projects between organizations with Resource Manager
Google Cloud Tech
29 How to run #MySQL in Google Cloud
How to run #MySQL in Google Cloud
Google Cloud Tech
30 #GenerativeAI for enterprises and #Next2023
#GenerativeAI for enterprises and #Next2023
Google Cloud Tech
31 How Google Photos scales to store 4 trillion photos and videos
How Google Photos scales to store 4 trillion photos and videos
Google Cloud Tech
32 Google Cross-Cloud Interconnect (Demo 2)
Google Cross-Cloud Interconnect (Demo 2)
Google Cloud Tech
33 GKE Cost Optimization Golden Signals: Introduction
GKE Cost Optimization Golden Signals: Introduction
Google Cloud Tech
34 GKE Cost Optimization Golden Signals: Workload Rightsizing
GKE Cost Optimization Golden Signals: Workload Rightsizing
Google Cloud Tech
35 GKE Load Balancing: Overview
GKE Load Balancing: Overview
Google Cloud Tech
36 GKE Load Balancing: Best Practices
GKE Load Balancing: Best Practices
Google Cloud Tech
37 Disaster Recovery in GKE
Disaster Recovery in GKE
Google Cloud Tech
38 How to configure IP masquerade agent in GKE Standard clusters
How to configure IP masquerade agent in GKE Standard clusters
Google Cloud Tech
39 Enable and use GKE Control plane logs
Enable and use GKE Control plane logs
Google Cloud Tech
40 Compliance in Australia with Assured Workloads
Compliance in Australia with Assured Workloads
Google Cloud Tech
41 Creating budgets and budget alerts in Google Cloud #FinOps
Creating budgets and budget alerts in Google Cloud #FinOps
Google Cloud Tech
42 Cloud SQL Enterprise Plus on our radar #mySQL
Cloud SQL Enterprise Plus on our radar #mySQL
Google Cloud Tech
43 What's Next for Google Cloud?
What's Next for Google Cloud?
Google Cloud Tech
44 How Loveholidays scaled with Contact Center AI
How Loveholidays scaled with Contact Center AI
Google Cloud Tech
45 What is fleet team management in GKE?
What is fleet team management in GKE?
Google Cloud Tech
46 Troubleshoot VPC Network Peering
Troubleshoot VPC Network Peering
Google Cloud Tech
47 Introduction to DocAI and Contact Center AI
Introduction to DocAI and Contact Center AI
Google Cloud Tech
48 Cloud Run Direct VPC egress explained
Cloud Run Direct VPC egress explained
Google Cloud Tech
49 Database deployment options in GKE
Database deployment options in GKE
Google Cloud Tech
50 Analyze cloud billing data with #BigQuery
Analyze cloud billing data with #BigQuery
Google Cloud Tech
51 Tips to becoming a world-class Prompt Engineer
Tips to becoming a world-class Prompt Engineer
Google Cloud Tech
52 Serverless is simple. Do I need CI/CD?
Serverless is simple. Do I need CI/CD?
Google Cloud Tech
53 Accelerating model deployment with MLOps
Accelerating model deployment with MLOps
Google Cloud Tech
54 How Hawaii's Department of Human Services scaled with CCAI
How Hawaii's Department of Human Services scaled with CCAI
Google Cloud Tech
55 Pricing API on our #Radar
Pricing API on our #Radar
Google Cloud Tech
56 How Recommendations AI for Media can boost customer retention
How Recommendations AI for Media can boost customer retention
Google Cloud Tech
57 Troubleshooting: Node Not Ready Status
Troubleshooting: Node Not Ready Status
Google Cloud Tech
58 One weekend until Cloud Next 2023!
One weekend until Cloud Next 2023!
Google Cloud Tech
59 #GoogleCloudNext starts tomorrow!
#GoogleCloudNext starts tomorrow!
Google Cloud Tech
60 #GoogleCloudNext will be demand!
#GoogleCloudNext will be demand!
Google Cloud Tech

Related Reads

📰
Open-Weight LLM API Integration: A Developer Guide to Building with Transparent AI
Learn to integrate open-weight LLM APIs for transparent AI, enabling fine-grained control and inspecting the architecture behind the intelligence
Dev.to AI
📰
Stop Writing Boilerplate: How I Automated My Entire Workflow with LLM APIs
Automate your LLM workflow using APIs to reduce repetitive code, increasing productivity and efficiency
Dev.to AI
📰
The real AI race may no longer be at the frontier
The AI race may shift from frontier models to open models due to cost, accessibility, and ownership, impacting production AI and enterprise adoption
TechCrunch AI
📰
Building a Document-RAG Agent on GCP's Agent Development Kit (ADK)
Learn to build a Document-RAG agent on GCP's Agent Development Kit (ADK) for efficient document-based conversational AI
Dev.to · Dale Nguyen
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →