Skip to content

Training runtimes

A training runtime is a named bundle of defaults for a Kubeflow TrainJob: which container image to start, what environment variables to set, what volumes to mount, and how many nodes to use when you don't say otherwise. You reference a runtime by name in the Python SDK (runtime="torch-rtxa6000") or in a YAML manifest (spec.runtimeRef.name: torch-rtxa6000); everything in the runtime is merged with whatever you specify yourself.

On FLAME, the runtime you choose also chooses your GPU type. There is one runtime per GPU class, named torch-<class> (for example torch-rtxa6000). Naming the runtime is how you select the hardware your job runs on. There is deliberately no general-purpose, GPU-agnostic runtime — every TrainJob names a specific class.

Available runtimes

FLAME provides one torch-<class> runtime for each GPU class currently installed in the cluster. To see exactly which runtimes exist right now:

kubectl get clustertrainingruntimes

or, from Python:

from kubeflow.trainer import TrainerClient
for rt in TrainerClient().list_runtimes():
    print(rt.name)

The currently available runtimes are:

Runtime GPU class Kueue flavor Node architecture GPUs per node
torch-b200 NVIDIA B200 b200 amd64 8
torch-gh200 NVIDIA GH200 gh200 arm64 1
torch-rtxa6000 NVIDIA RTX A6000 rtxa6000 amd64 8

See GPUs for specifications and help choosing a class.

Runtime defaults

Both runtimes use the same defaults apart from their hardware selector:

Property Value
Default container image registry.flamecluster.io/urcf/pytorch, pinned to a specific release
Default numNodes 1
Default numProcPerNode unset (Kubeflow Trainer default: one process per GPU requested)
Default GPU resources none — you supply resourcesPerNode
Default CPU / memory / scratch disk 1 CPU / 2 GiB / 5 GiB per node — see CPU, memory, and scratch disk
Failure handling no automatic retry of a failed training command; one restart of the whole job after an infrastructure disruption
Working directory /tmp (pod-local temporary storage)

The default image is URCF's own PyTorch image, built and kept up to date for FLAME. It includes PyTorch and the CUDA libraries needed on FLAME's GPUs. Because it is built for both arm64 and amd64, it works on either GPU class without any extra steps from you.

TrainJobs start in temporary storage

TrainJobs using the stock runtimes start in pod-local /tmp. Relative paths resolve there, and files saved there are temporary. Save results under /home/ubuntu or /workspace to keep them after the pod is removed.

To work in your project directory, change directories at the start of your training function:

import os

os.chdir("/home/ubuntu/projects/my-project")

For a subprocess, use subprocess.run(..., cwd="/home/ubuntu/projects/my-project"). The directory must already exist. Changing directories in your notebook does not set the TrainJob's working directory.

Environment variables set by the runtime:

Variable Value Effect
XDG_CACHE_HOME /home/ubuntu/.cache pip, HuggingFace Hub, and torch.hub caches go to your home volume
TRITON_CACHE_DIR /home/ubuntu/.cache/triton Triton kernel cache persists across runs
TORCHINDUCTOR_CACHE_DIR /home/ubuntu/.cache/torchinductor torch.compile cache persists across runs

Pointing caches at /home/ubuntu means they survive pod restarts and are shared between notebook sessions and TrainJobs in the same workspace.

Volumes mounted by the runtime:

A memory-backed /dev/shm is mounted automatically. This is required by PyTorch's multiprocessing data loaders (shared memory is how worker processes pass tensors to the training loop). Its size is bounded by the pod's memory limit.

Your home PVC and workspace PVC are also mounted automatically into every TrainJob — this is done cluster-wide, not by the runtime itself, so it applies to plain Jobs too.

More GPU classes appear as runtimes when hardware is added

As FLAME grows to include other GPU types, each one shows up as its own torch-<class> runtime (for example torch-h200 or torch-a100), built the same way as torch-rtxa6000. Run kubectl get clustertrainingruntimes for the current list rather than assuming a class exists.

Failures and retries

FLAME does not rerun a training command that fails. If any process in your TrainJob exits with an error, the TrainJob is marked failed straight away and its GPUs are released. FLAME cannot tell a bug in your code from a temporary problem such as a failed download: both end with the same exit code. Rerunning a bug only repeats the crash while holding GPUs other researchers are waiting for.

The pod that crashed is kept, so you can debug it with the usual Kubernetes tools:

$ kubectl get pods -l jobset.sigs.k8s.io/jobset-name=<trainjob-name>
$ kubectl logs <pod-name>
$ kubectl describe pod <pod-name>

kubectl describe pod shows the exit code and reason. A pod that ran out of memory shows OOMKilled there, and its log simply stops. Failed pods stay until workload cleanup removes them after 14 days. In a multi-node job, FLAME stops the other workers when one fails, so only the pod that crashed is guaranteed to remain.

The URCF images set two Python options that make these logs more useful:

  • PYTHONUNBUFFERED=1: print() output reaches the log as soon as it is written, so you can follow progress live and the last lines before an OOMKilled are not lost.
  • PYTHONFAULTHANDLER=1: a crash inside native code such as PyTorch, CUDA, or NCCL (exit code 139, a segmentation fault) prints a Python traceback for every thread, showing which line of your code was running.

Custom images built FROM a URCF base image inherit both. Set them yourself (ENV PYTHONUNBUFFERED=1 PYTHONFAULTHANDLER=1) in images built from anything else.

Once you have fixed the problem, submit the TrainJob again under a new name.

Infrastructure disruptions are the exception. If a pod is lost because its node failed, was drained for maintenance, or evicted the pod, FLAME restarts the whole TrainJob once. Every worker starts again together, so a multi-node job re-forms as a group. The pods from the interrupted attempt are removed. A second disruption marks the TrainJob failed.

A restart runs your command again from the beginning. Save checkpoints under /home/ubuntu or /workspace and load the latest one at startup, or the restarted job repeats work it already did.

Making your own job resilient

Recovering from failures inside your training run is up to your code:

  • Checkpoint regularly. It protects you from disruptions and makes a manual resubmission cheap.
  • Retry flaky calls where they happen. Wrap downloads and calls to outside services in a retry. The HuggingFace Hub client retries on its own and can be tuned with HF_HUB_DOWNLOAD_TIMEOUT and HF_HUB_ETAG_TIMEOUT.
  • Restart workers inside the pod. If you launch torchrun yourself, --max-restarts=<n> restarts all workers in the pod when one fails, without losing the pod or its logs.

These are defaults of FLAME's ClusterTrainingRuntime resources. For a different policy, create your own TrainingRuntime in your namespace and reference it with spec.runtimeRef.kind: TrainingRuntime. Keep the GPU selector from the stock runtime for your chosen GPU class.

How choosing a runtime selects your GPU

Each torch-<class> runtime carries a nodeSelector that pins your pods to nodes of that GPU class. That same selector is what Kueue uses to admit your job against the matching resource flavor.

For example, naming torch-gh200 lands your pods on GH200 nodes and routes the job through the gh200 flavor of your research group's allocation. torch-rtxa6000 does the same for RTX A6000 nodes and the rtxa6000 flavor. You never set a nodeSelector or flavor name yourself — picking the runtime is the whole interface.

The GPU hardware

FLAME has B200, GH200, and RTX A6000 GPU nodes. They differ in memory, CPU architecture, and the number of GPUs available on one node. See GPUs for the current capacity, verified specifications, and selection guidance.

Queue and scheduling

You do not need to set a Kueue queue name on your TrainJob — it is injected automatically. The GPU flavor is selected by the runtime you chose (via its nodeSelector, as described above), and Kueue then schedules your job against your research group's allocation for that flavor.

A TrainJob shows Suspended while it waits in the queue. To see why a job is still waiting — for example, because your group's GPUs are in use — look at its Kueue workload:

kubectl get workloads
kubectl describe workload <workload-name>

The workload's name starts with trainjob-<your-job-name>, and the reason is in its conditions and events.

Specifying GPU resources

The runtime does not request any GPUs by default — you must ask for them explicitly. In the Python SDK, use the resources_per_node argument:

from kubeflow.trainer import TrainerClient, CustomTrainer

client = TrainerClient()
job_name = client.train(
    runtime="torch-rtxa6000",
    trainer=CustomTrainer(
        func=my_train_fn,
        resources_per_node={"cpu": 8, "memory": "64Gi", "gpu": 1},  # (1)
    ),
)
  1. "gpu": 1 requests one RTX A6000. The RTX A6000 node has eight GPUs, so the maximum for a single-node job is 8.

In a YAML manifest, the equivalent looks like:

apiVersion: trainer.kubeflow.org/v1alpha1
kind: TrainJob
metadata:
  name: my-job
spec:
  runtimeRef:
    name: torch-rtxa6000
  trainer:
    resourcesPerNode:
      requests:
        cpu: "8"
        memory: "64Gi"
        nvidia.com/gpu: "1"
      limits:
        nvidia.com/gpu: "1"

CPU, memory, and scratch disk

Set CPU and memory alongside your GPUs in resourcesPerNode. Anything you leave out gets a small default:

Resource Default per node
CPU (cpu) 1
Memory (memory) 2 GiB
Scratch disk (ephemeral-storage) 5 GiB

These defaults are too small for most training, so set cpu and memory explicitly. You can put the values under requests, limits, or both; if you give only one, FLAME uses the same value for the other on the pods it creates. (GPUs are different: nvidia.com/gpu must always appear under limits.) What you ask for is reserved for your job, and it is also a hard cap:

  • A process that uses more memory than its limit is killed (the pod shows OOMKilled, exit code 137).
  • A pod that writes more than its scratch disk limit to pod-local storage is evicted. Pod-local storage includes /tmp, the runtime's working directory, so write datasets, checkpoints, and other large files under /home/ubuntu or /workspace instead. If you need more local scratch, set ephemeral-storage in resourcesPerNode.

Using a custom image

To override the default image, pass image in the SDK or set spec.trainer.image in YAML. The image must be built for the CPU architecture of the GPU class you chose — GH200 nodes are arm64, while B200 and RTX A6000 nodes are amd64. See Building a custom container image for how to produce one through FLAME's CI system.

Inspecting runtimes

To see the full definition of a runtime:

kubectl get clustertrainingruntime torch-rtxa6000 -o yaml

To list all available runtimes (one per GPU class):

kubectl get clustertrainingruntimes