GKE AI Inference Deployment

GKE AI Inference Deployment

Deploys and tunes AI inference workloads on GKE with GPUs, TPUs and model servers, generating optimised Kubernetes manifests for LLM serving.

Skill files2 files

references/

SKILL.md226 lines
1
---
2
name: gke-inference
3
description: >-
4
Deploys and optimizes AI/ML inference workloads on GKE, using GPUs, TPUs, and
5
model servers. Use when deploying GKE inference servers, configuring GKE GPU
6
resources for inference, or deploying LLMs on GKE. Don't use for migrating
7
existing AI workloads to GKE (use google-cloud-solution-guided-gke-ai-migration),
8
GKE RAG with Cloud SQL/AlloyDB (use google-cloud-solution-rag-enterprise-search-gke-sqldb),
9
or batch/HPC (use gke-batch-hpc).
10
metadata:
11
version: "1.0.3"
12
category: Containers
13
---
14
15
# GKE AI/ML Inference
16
17
> **Routing Note:** For migrating existing AI workloads to GKE, refer to the
18
> `google-cloud-solution-guided-gke-ai-migration` skill. For GKE RAG with Cloud
19
> SQL or AlloyDB (`pgvector`), refer to the
20
> `google-cloud-solution-rag-enterprise-search-gke-sqldb` skill.
21
22
This reference covers deploying AI/ML inference workloads on GKE using Google's
23
Inference Quickstart (GIQ) and best practices for LLM serving.
24
25
> **MCP Tools:** `apply_k8s_manifest`, `get_k8s_resource`, `get_k8s_logs`,
26
> `get_k8s_rollout_status`, `describe_k8s_resource`, `list_k8s_events`.
27
> **CLI-only:** `gcloud container ai profiles *`
28
29
## Attribution
30
31
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
32
MUST read [Usage Attribution](references/attribution.md). For commands executed
33
directly in the terminal (never in generated scripts, Terraform, or user code),
34
prefix `gcloud` with
35
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-inference)"`
36
and append `agent-skills/1.0 (skill:gke-inference)` to `User-Agent` headers.
37
38
## When to Use
39
40
- Deploy an AI model (Llama, Gemma, Mistral, etc.) to GKE
41
- Generate optimized Kubernetes manifests for inference
42
- Select GPU/TPU accelerators for model serving
43
- Configure autoscaling for LLM inference
44
45
## Prerequisites
46
47
- A golden path GKE Autopilot cluster (GPU workloads are supported via
48
ComputeClasses and NAP)
49
- `gcloud` CLI authenticated
50
- Sufficient GPU/TPU quota in the target region
51
52
## Workflow
53
54
### 1. Discovery: Find Models and Hardware
55
56
```bash
57
# List all supported models
58
gcloud container ai profiles models list --quiet
59
60
# Find valid accelerator/server combinations for a model
61
gcloud container ai profiles list --model=<MODEL_NAME> --quiet
62
63
# Example: what can run Gemma 2 9B?
64
gcloud container ai profiles list --model=gemma-2-9b-it --quiet
65
```
66
67
### 2. Generate Manifest
68
69
```bash
70
gcloud container ai profiles manifests create \
71
--model=<MODEL_NAME> \
72
--model-server=<SERVER> \
73
--accelerator-type=<ACCELERATOR> \
74
--target-ntpot-milliseconds=<NTPOT> --quiet > inference.yaml
75
```
76
77
**Parameters:**
78
79
- `--model`: Model ID (e.g., `gemma-2-9b-it`, `llama-3-8b`)
80
- `--model-server`: Inference server (`vllm`, `tgi`, `triton`, `tensorrt-llm`)
81
- `--accelerator-type`: GPU/TPU type (`nvidia-l4`, `nvidia-tesla-a100`,
82
`nvidia-h100-80gb`)
83
- `--target-ntpot-milliseconds`: Target Normalized Time Per Output Token
84
(optional, for latency optimization)
85
86
**Example:**
87
88
```bash
89
gcloud container ai profiles manifests create \
90
--model=gemma-2-9b-it \
91
--model-server=vllm \
92
--accelerator-type=nvidia-l4 \
93
--target-ntpot-milliseconds=50 --quiet > inference.yaml
94
```
95
96
### 3. Review and Deploy
97
98
```bash
99
# Review for placeholders (HF tokens, PVCs)
100
cat inference.yaml
101
102
# Deploy
103
kubectl apply -f inference.yaml
104
105
# Monitor
106
kubectl get pods -w
107
kubectl logs -f <POD_NAME>
108
```
109
110
> Some models require Hugging Face tokens. Create a Kubernetes Secret and
111
> reference it in the manifest.
112
113
## GPU ComputeClass for Inference
114
115
For Autopilot clusters, create a ComputeClass to target GPU nodes:
116
117
```yaml
118
apiVersion: cloud.google.com/v1
119
kind: ComputeClass
120
metadata:
121
name: l4-inference
122
spec:
123
priorities:
124
- machineFamily: g2
125
gpu:
126
type: nvidia-l4
127
count: 1
128
minCores: 4
129
minMemoryGb: 16
130
```
131
132
## Accelerator Selection Guide
133
134
| Accelerator | Best For | Memory | Relative Cost |
135
| ------------------- | ------------------------ | ----------- | ------------- |
136
| NVIDIA T4 | Budget inference, | 16 GB | Lowest |
137
: : lightweight legacy : : :
138
: : models : : :
139
| NVIDIA L4 (G2) | Small-medium model | 24 GB | Low |
140
: : inference, video, : : :
141
: : graphics : : :
142
| NVIDIA RTX PRO 6000 | Multimodal AI, | 96 GB | Medium |
143
: (G4) : high-fidelity 3D, : : :
144
: : fine-tuning : : :
145
| Cloud TPU v5e | Cost-effective | Varies | Medium |
146
: : transformer inference : : :
147
| Cloud TPU v5p | High-performance | Varies | High |
148
: : training : : :
149
| Cloud TPU v6e | High-efficiency next-gen | 32 GB/chip | Medium-High |
150
: (Trillium) : training & serving : : :
151
| Cloud TPU v7x | Ultra-scale inference & | 192 GB/chip | High |
152
: (Ironwood) : agentic workflows : : :
153
| NVIDIA A100 | Large model inference, | 40/80 GB | High |
154
: : enterprise ML : : :
155
| NVIDIA H100 / H200 | Frontier model training, | 80/141 GB | Highest |
156
: : high throughput : : :
157
| NVIDIA B200 (A4) | Blackwell-scale | 192 GB | Highest |
158
: : training, FP4 precision : : :
159
| NVIDIA GB200 (A4X) | Rack-scale AI (Grace | Massive | Highest |
160
: : Blackwell Superchip) : : :
161
162
## Autoscaling LLM Inference
163
164
### GPU-based autoscaling
165
166
Use custom metrics for GPU utilization:
167
168
```yaml
169
apiVersion: autoscaling/v2
170
kind: HorizontalPodAutoscaler
171
metadata:
172
name: llm-hpa
173
spec:
174
scaleTargetRef:
175
apiVersion: apps/v1
176
kind: Deployment
177
name: llm-server
178
minReplicas: 1
179
maxReplicas: 10
180
metrics:
181
- type: Pods
182
pods:
183
metric:
184
name: gpu_duty_cycle
185
target:
186
type: AverageValue
187
averageValue: "80"
188
```
189
190
### Best practices for inference autoscaling
191
192
1. **Use DCGM metrics**: Golden path enables DCGM monitoring for GPU
193
utilization metrics
194
2. **Set appropriate minReplicas**: At least 1 for always-on serving; 0 for
195
batch/on-demand
196
3. **Tune scale-down delay**: LLM model loading is slow; use longer
197
stabilization windows
198
4. **Consider queue depth**: Scale on pending requests rather than pure GPU
199
utilization for latency-sensitive workloads
200
201
## Optimization Tips
202
203
- **Quantization**: Use quantized models (GPTQ, AWQ) to reduce GPU memory and
204
increase throughput
205
- **Batching**: Configure model server batch size for throughput vs latency
206
trade-off
207
- **Tensor parallelism**: Split large models across multiple GPUs within a
208
node
209
- **KV cache optimization**: Tune `--gpu-memory-utilization` in vLLM for KV
210
cache allocation
211
212
## Troubleshooting
213
214
| Issue | Cause | Fix |
215
| ------------------ | ------------------------ | --------------------------- |
216
| Invalid | Unsupported tuple | Re-run `gcloud container ai |
217
: model/accelerator : : profiles list :
218
: combination : : --model=<MODEL>` :
219
| GPU quota exceeded | Regional quota limit | Request quota increase or |
220
: : : try a different region :
221
| OOM on GPU | Model too large for | Use larger GPU, enable |
222
: : accelerator : quantization, or use tensor :
223
: : : parallelism :
224
| Slow cold start | Large model loading from | Use local SSD for model |
225
: : registry : caching; pre-pull images :
226

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…