Skip to main content
Training Jobs runs your training code in a container on the compute you choose, and groups related jobs into training projects. If you’d rather fine-tune or run RL through a managed Python SDK, see Loops.

Projects, jobs, and configuration

A training job starts from a directory on your machine. baseten train push packages that directory and runs your start commands in a container, so the directory holds everything the job reads: the config file, your training scripts, and any data files your code opens. The directory must contain a config file, such as config.py, that declares the job. Its start_commands list runs when the container starts, and can run a Python file (python train.py) or a shell script (chmod +x run.sh && ./run.sh) that installs dependencies the image lacks and then starts training. To start from an existing example, run baseten train init with an example name. baseten train init --example mnist-pytorch creates a CPU-only PyTorch job, and baseten train init --example oss-gpt-20b-axolotl creates a multi-GPU job. The quickstart builds a complete project from an empty directory.
To train on more than 1 GB of data, upload the data to object storage and download it from a start command instead of including it in the project directory. The training cache keeps later jobs from downloading it again. See Storage for training jobs for the storage options.

Organize jobs into a TrainingProject

A TrainingProject groups related TrainingJobs. Jobs in the same project share a training cache, and the project name identifies them when another job loads their checkpoints or a deployment reads them.

Run a TrainingJob

A TrainingJob is one execution of your training script. It bundles:
  • Your training code.
  • A base image.
  • The compute resources to run on.
  • The runtime settings, such as start commands and environment variables.
To try a different learning rate, more GPUs, or a changed script, create another TrainingJob and keep the earlier one. A job moves through TRAINING_JOB_CREATED, TRAINING_JOB_DEPLOYING, TRAINING_JOB_RUNNING, and a terminal state such as TRAINING_JOB_COMPLETED. See Job lifecycle for every state.

Compute resources

The Compute configuration sets what the job runs on:
  • GPU specifications: Choose from the available GPU types based on your model’s requirements.
  • CPU and memory: Set the CPU and RAM allocated to the job.
  • Node count: Train on a single node or across multiple nodes.
Training Jobs supports H200 and H100 GPUs. Choose the GPU type based on your model’s memory requirements and performance needs.

CPU-only jobs

GPU allocation is optional. Omit accelerator from Compute to run a CPU-only job, which is useful for data preparation, smoke tests, or lightweight training workloads (such as the mnist-pytorch example):
config.py
CPU-only training jobs are not subject to the 16-vCPU limit that applies to CPU-only inference deployments. Set cpu_count and memory to the values your workload needs. If you hit a ceiling when requesting a larger allocation, Contact us.

Base images

Baseten provides pre-configured base images that include common ML frameworks and dependencies for training workloads:
  • Popular ML frameworks (PyTorch, VERL, Megatron, Axolotl, etc.).
  • GPU drivers and CUDA support.
  • Common data science libraries.
For specific requirements, use a custom or private image. For private AWS ECR or Google Cloud registries, configure docker_auth with OIDC (recommended) or AWS AssumeRole. These methods use short-lived credentials instead of storing registry credentials in Baseten.
First, configure AWS to trust the Baseten OIDC provider and grant the role permission to pull from your ECR repository.
config.py
For static credentials and other private registries, see the Training SDK DockerAuth reference.

Reference secrets with SecretReference

Training often needs credentials for services such as Weights & Biases or Hugging Face. Store each value as a Baseten secret with a specific name, then refer to it from the job with the SecretReference class. Baseten injects the secret value at runtime under the environment variable name you set, and the value never appears in your code.

Run inference on trained models

To serve a trained model:
  1. A TrainingJob with checkpointing enabled produces one or more model artifacts.
  2. Run baseten train checkpoint deploy to deploy a model from your most recent training job. See Deploy a Training Jobs checkpoint.
  3. The deployed model serves inference through the API. See Call your model.

Next steps