MLOps Foundations
Advanced 16 min read MLOps Foundations

Training Infrastructure

From someone's laptop to a scheduler anyone can use

Training infrastructure turns ad-hoc compute into scheduled, reproducible, shareable runs: GPU allocation, containers, orchestration, experiment parallelism and cost control — all pinned to the exact environment a model needs.

GPUcomputecontainerorchestrationKubernetesdistributed trainingcostelastic
Before we start

What you will learn

  • Design a training platform: containers, queues, scheduling and GPUs
  • Explain determinism, resource isolation and cost control on shared compute
  • Recognize when distributed training is worth it
Introduction

What is this?

Training infrastructure is the machinery that runs training at scale with discipline: a containerized, versioned environment; a scheduler that allocates CPU/GPU, enforces resource limits and queues jobs; and experiment orchestration that tracks each run. The goal is that a command line can reproduce any training run, that jobs share scarce GPUs safely, and that cost and utilization are visible instead of mystical.

Motivation

Why do you need it?

  • Models and data grow faster than laptops; training needs determinism that notebooks can't give.
  • Shared GPUs without scheduling cause collisions, blasts of 'my job OOMed' and untracked spend.
  • Containerized environments end 'works on my machine' version rot across runs.
  • Reproducibility in an audit/production context demands pinned environments and logged runs.
Think about it

Mental model

Imagine

A shared kitchen with one stove

Think of

Shared training compute

Everyone cooking simultaneously burns dinner and fights for burners. A restaurant with reservations (scheduling), standardized recipes (containers) and a prep order (orchestration) gets more meals cooked in less time — and you can say exactly what each dish contained.

Mechanics

How it works

  • Containerize: image pins Python, CUDA and library versions; the image IS the training environment.
  • Schedule: jobs request CPUs/GPUs and memory; a scheduler (Kubernetes jobs, Slurm) queues, retries and evicts.
  • Run: orchestrators mount datasets, set seeds and env vars, write metrics and artifacts to a tracking server.
  • Scale: one GPU per job by default; distributed strategy (multi-worker) only when a single GPU is insufficient.
  • Govern: budget per team/experiment, quotas, spot-instance policies and usage dashboards.

A minimal training platform flow.

Code + data
Container image
Scheduler
Training run
Registry / tracker
Real world

In production

  • A research team runs hundreds of hyperparameter trials on a Kubernetes GPU pool, each job a container with pinned image and a 2-GPU request.
  • An e-commerce ML team uses spot instances for preemptible batch training, keeping interactive GPU quotas for critical runs.
  • A large-scale recommendation model trains distributed across 8 nodes with gradient synchronization when one GPU is too slow.
Guidelines

Best practices

  • Pin the full env: Python, CUDA, framework versions, plus a lockfile — and record it per run.
  • Give every run a unique ID and log code hash, dataset version and hyperparameters as structured metadata.
  • Set resource requests/limits so a runaway job can't starve neighbors.
  • Keep datasets versioned and mounted read-only; never train on mutable files.
  • Track utilization and cost per team before you scale the platform.
Watch out

Common mistakes

  • Running GPU jobs on the CPU pool 'because it's free' — orders of magnitude slower and still costs.
  • Installing packages at job start via pip inside containers, reintroducing version drift.
  • Ignoring OOM kills: a transient spike kills a 10-hour run without checkpointing.
  • Pretending multi-GPU/distributed is free — communication overhead can make it slower.
Root cause analysis

Common issues

Error
GPU shows 0% utilization during training
Root cause

Data loading/serialization bottleneck or tiny batch CPU-bound

Fix

Improve dataloader parallelism, prefetch/Augment asynchronously, and measure CPU% during GPU waits.

Error
Job runs but results differ from the previous run
Root cause

Unpinned deps, missing seed, or dataset changed in place

Fix

Pin image, set seeds, freeze and hash the dataset, log everything in run metadata.

Error
OOM kills a long training job
Root cause

Memory request underprovisioned or growth (cache/checkpoints) unbounded

Fix

Add checkpointing + resume, raise limits for known-peak runs, and test memory profile on one batch first.

When things break

Debugging tips

  • Reproduce locally or on a tiny sample first; GPU queue time is too expensive a debugger.
  • Check GPU utilization (nvidia-smi) — low utilization means I/O or serialization bottleneck, not more GPUs.
  • Enable checkpointing with resume; most long-job failures are transient (eviction, OOM, node loss).
  • Compare two identical run IDs with different images to isolate dependency-induced nondeterminism.
Interviews

Interview checkpoint

Practice

Hands-on lab

Reproducible Training with a Pinned Environment
30 min · intermediate
In progress
Objectives
  • Pin Python and scikit-learn versions to a fixed environment
  • Train a model twice from the same seed and dataset and prove identical results
  • Record run metadata (git-style hash of inputs + metrics) as a light registry handoff

Reproducible Training with a Pinned Environment

30 min · intermediate

0/5 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

GPU utilization is 15% during training. The likely cause is:

2

Distributed training always makes training faster.

Go deeper

Official documentation