Course: Cloud Computing Technologies
Presenter: Stefano Galantino, Politecnico di Torino
Source: AI in Kubernetes, 41 PDF pages (printed slides 1–27 and 30–44; printed slides 28–29 and 34 are absent).
Lecture numbering: 17 is inferred from its position in the course sequence after Lecture 16. The source was supplied in the study session and remains outside the published resources.

Learning route

Lecture 11 introduced Kubernetes Pods, Operators, and Prometheus observability (Lecture 12), while Lecture 16 covered datacenter GPU cooling and bare-metal Kubernetes clusters. This lecture examines how Kubernetes orchestrates GPUs for AI workloads across three parts. Part I: Infrastructure (PDF pp. 2–10 / printed slides 2–10) explains the Device Plugin Framework, why manual GPU stack setup fails, how the NVIDIA GPU Operator automates drivers, Container Toolkit, GFD, DCGM, and validator pods, and why One-GPU-Per-Pod leaves GPUs around ~30% utilized. Part II: GPU Sharing & Partitioning (PDF pp. 11–27 / printed slides 11–27) compares Time-Slicing, MPS, and MIG across isolation, memory contention (“Busy Neighbour”), Kubernetes Single/Mixed strategies, MIG Manager, and GPU hardware support. Part III: Applications (PDF pp. 28–41 / printed slides 30–44) shows why static Pod-lifetime GPU allocations still waste cycles on bursty AI traffic and introduces FaaS (OpenFaaS, Knative, Fission, KServe, KubeRay), Ray Core, and the RayCluster CRD.

Exam priorities

Focus on: how the Device Plugin Framework exposes GPUs to kubelet and Pods (nvidia.com/gpu: 1); the components and roles inside the NVIDIA GPU Operator (Driver Manager, Container Toolkit, Device Plugin + GFD, DCGM → Prometheus, Validator Pods); the One-GPU-Per-Pod ~30% utilization problem; comparing Time-Slicing, MPS (client–server single CUDA context, Hyper-Q, hard VRAM limits vs. shared L2/bandwidth “Busy Neighbour” 30%+ slowdown), and MIG (physical GPC isolation of SMs, L2, DRAM BW, Single vs. Mixed MIG, MIG Manager); which GPUs support MIG vs. L4/L40S/T4/A10; why bursty workloads outgrow static Pod allocations and motivate FaaS; and Ray Core (@ray.remote Tasks vs. Actors) plus KubeRay’s RayCluster (headGroupSpec vs. workerGroupSpecs, minReplicas/maxReplicas). Specific A100/A30 slice counts, Llama 3.1/3.2 benchmark numbers, Ray container version (2.9.0), and exact port numbers (6379/8265/10001) are supporting details.

Part I: Infrastructure — Device Plugins and the NVIDIA GPU Operator

Core Kubernetes only tracks CPU and memory natively, so specialized accelerators (GPUs, NICs, FPGAs) register through the Device Plugin Framework: a vendor plugin informs kubelet, kubelet reports healthy counts to the API server, and Pods request GPUs via resources.limits: nvidia.com/gpu: 1 (PDF pp. 3–4 / printed slides 3–4). Manually matching NVIDIA drivers, container runtimes (containerd/CRI-O), and CUDA libraries across every node is error-prone, so the NVIDIA GPU Operator automates the full lifecycle atop a uniform Gold Master Image (PDF pp. 5–9 / printed slides 5–9): Driver Manager installs a containerized driver per node to keep the host OS clean; Container Toolkit wires GPU device nodes and libraries into containerd/CRI-O; Device Plugin + GPU Feature Discovery (GFD) advertise GPUs and label nodes with model, memory, and driver version; DCGM exports telemetry to Prometheus; and validator pods confirm CUDA works post-install. Even so, the default Device Plugin allocates GPUs as indivisible integer units, locking an entire H100/H200 to one Pod and leaving many datacenter GPUs at ~30% utilization (PDF p. 10 / printed slide 10). Kubernetes GPU Orchestration and NVIDIA GPU Operator

Part II: GPU Sharing and Partitioning

To raise utilization, GPU partitioning moves across four layers from orchestration to software sharing (Time-Slicing, MPS) and hardware slicing (MIG) up to PCIe network composability (PDF p. 11 / printed slide 11):

  • Time-Slicing (PDF pp. 12–13, 24): Advertising virtual GPU replicas triggers temporal context switching (saving/loading hundreds of MB per switch). It allows oversubscription for dev/idle workloads, but offers zero memory or fault isolation (one crash can hit all sharing Pods) and risks stale high-latency tasks.
  • MPS — Multi-Process Service (PDF pp. 14–18, 24–25): A client–server CUDA API where one MPS Server funnels MPS Clients through a single CUDA context so Hyper-Q runs kernels simultaneously with software QoS and hard per-client memory capacity limits. However, L2 cache and memory bandwidth remain shared, causing a “Busy Neighbour” slowdown of 30%+ on memory-heavy workloads (slide 17 shows a 12.5% share falling from 1.800 alone to 755), though MPS can beat MIG on compute-heavy cooperative tasks.
  • MIG — Multi-Instance GPU (PDF pp. 19–27): Available on Ampere and newer top-tier GPUs (A30, A100, H100), MIG partitions at the GPC level into isolated mini-GPUs (e.g., 3g.20gb; A100 up to 7 instances) with dedicated SMs, L2 cache, memory controllers, and DRAM bandwidth for deterministic multi-tenant SLAs, though hard boundaries block bursting. Kubernetes supports Single MIG (nvidia.com/gpu) and Mixed MIG (nvidia.com/mig-3g.20gb), while MIG Manager re-partitions dynamically via node labels. Cost-effective cards (L4, L40S, T4, A10) lack MIG and rely on MPS/Time-Slicing (up to 10 temporal vGPU instances). Spatial sharing raises instantaneous power draw but often reduces total energy by finishing work sooner. GPU Sharing and Partitioning - Time-Slicing MPS and MIG

Part III: Applications — Bursty Workloads, FaaS, Ray Core, and KubeRay

Even with MPS or MIG, Kubernetes binds GPU resources for the entire lifetime of a Pod (PDF pp. 29–31 / printed slides 31–33; slide 32 illustrates Cloud GPU inference throughput outperforming Cloud CPU and Edge across Llama 3.1/3.2 models). Because AI workloads arrive in bursts separated by idle gaps, static Pod-bound GPU slices sit idle between bursts instead of tightly interleaving across applications (PDF pp. 32–33 / printed slides 35–36).

Function-as-a-Service (FaaS) addresses this via event-driven, short-lived, rapidly scaling functions that multiplex bursts onto accelerators (general K8s: OpenFaaS, Knative, Fission; AI-specific: KServe, KubeRay; PDF pp. 34–35 / printed slides 37–38). For distributed Python AI workloads, Ray Core turns functions decorated with @ray.remote into stateless Tasks (and decorated classes into stateful Actors) scheduled automatically across workers (PDF p. 36 / printed slide 39). KubeRay wraps Ray in an official Kubernetes Operator where nodes run as Pods declared via the RayCluster CRD (apiVersion: ray.io/v1): headGroupSpec defines the single coordinator Head Pod (Ray GCS 6379, Dashboard 8265, Client 10001 behind a ClusterIP Service), and workerGroupSpecs defines Worker Pods with starting replicas and Ray Autoscaler bounds (minReplicas, maxReplicas) continuously reconciled against failures (PDF pp. 37–41 / printed slides 40–44). Serverless AI on Kubernetes - FaaS Ray Core and KubeRay

Source map

PDF pagesPrinted slidesTopic
11Title (AI in Kubernetes, Stefano Galantino)
2–42–4Infrastructure: Kubernetes GPU orchestration & Device Plugin Framework (nvidia.com/gpu: 1)
5–95–9NVIDIA GPU Operator: Gold Master Image, Driver Manager, Container Toolkit, Device Plugin + GFD, DCGM, Lifecycle & Validator Pods
10–1110–11One-GPU-Per-Pod constraint (~30% utilization, H100/H200) & 4-layer GPU partitioning overview
12–1312–13Time-Slicing: Temporal context switching, virtual replicas oversubscription, isolation & stale-task limits
14–1814–18MPS: Hyper-Q gaps, Client–Server single CUDA context, VRAM limits vs. shared L2/BW (Busy Neighbour chart), GPU Operator integration
19–2319–23MIG: Physical GPC isolation (A100 7 instances, 3g.20gb), deterministic SLA performance, Single vs. Mixed MIG, MIG Manager
24–2724–27Comparisons & Hardware: Context-switch/hard-limit/L2 penalties, throughput & energy tradeoffs, 3-way table, compatible GPUs (L4, L40S, T4, A10)
28–3130–33Applications: Static vs. flexible sharing, Llama 3.1/3.2 throughput chart, Kubernetes extended resources (slides 28–29, 34 absent)
32–3535–38Bursty streams & FaaS: Interleaving burst gaps, FaaS GPU benefits, OpenFaaS / Knative / Fission / KServe / KubeRay
36–4139–44Ray Core & KubeRay: @ray.remote, KubeRay Operator, RayCluster CRD diagram + headGroupSpec & workerGroupSpecs YAML

Retrieval questions

  1. In the NVIDIA GPU Operator, distinguish what the Driver Manager, Container Toolkit, and GPU Feature Discovery (GFD) each configure.
    Driver Manager runs a containerized NVIDIA driver per node so the host OS remains a clean Gold Master Image; Container Toolkit hooks into containerd/CRI-O to expose GPU device nodes and libraries inside app containers; GFD labels Kubernetes Nodes with GPU model, memory, and driver version for the scheduler.
  2. A cluster runs untrusted multi-tenant inference services with strict latency SLAs on an A100, and both tenants have memory-heavy models. Why do Time-Slicing and MPS both fall short, and which MIG mode simplifies Pod requests?
    Time-Slicing lacks memory and fault isolation (one crash can disrupt every sharing Pod) and adds context-switching latency; MPS enforces VRAM caps but still shares L2 cache and DRAM bandwidth, causing 30%+ “Busy Neighbour” slowdowns. Hardware MIG isolates SMs, L2, and DRAM bandwidth, and Single MIG lets Pods request uniform nvidia.com/gpu rather than Mixed MIG profile names.
  3. Can an NVIDIA L4 or T4 node use MIG? What sharing options apply instead, and when can MPS outperform MIG?
    No—MIG is restricted to top-tier datacenter GPUs (e.g., A30, A100, H100), so L4/L40S/T4/A10 nodes use MPS or Time-Slicing (up to 10 temporal vGPU instances). MPS can outperform MIG on compute-intensive cooperative tasks without memory pressure because sharing is fluid rather than rigidly walled off.
  4. Why does static MIG partitioning still waste GPU capacity on bursty inference workloads, and how does FaaS help?
    Kubernetes holds a Pod’s GPU allocation for the Pod’s entire lifetime, leaving MIG slices idle between traffic bursts. FaaS uses event-driven, short-lived function executions that rapidly spin up for bursts and release accelerators immediately afterward.
  5. In KubeRay’s RayCluster CRD, what roles do headGroupSpec and workerGroupSpecs play, and how does @ray.remote relate to them?
    @ray.remote marks Python functions as stateless Tasks (or classes as Actors) in Ray Core; on Kubernetes, KubeRay schedules them across RayCluster Pods where headGroupSpec runs the single coordinator Head Pod (GCS 6379, Dashboard 8265, Client 10001) and workerGroupSpecs runs the autoscalable Worker Pods (replicas, minReplicas, maxReplicas).