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.
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
computeresources to run on. - The
runtimesettings, such as start commands and environment variables.
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
TheCompute 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.
CPU-only jobs
GPU allocation is optional. Omitaccelerator 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_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.
docker_auth with
OIDC (recommended) or AWS AssumeRole. These methods use short-lived credentials
instead of storing registry credentials in Baseten.
- AWS OIDC
- AWS AssumeRole
- GCP OIDC
First, configure AWS to trust the Baseten OIDC provider
and grant the role permission to pull from your ECR repository.
config.py
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:- A
TrainingJobwith checkpointing enabled produces one or more model artifacts. - Run
baseten train checkpoint deployto deploy a model from your most recent training job. See Deploy a Training Jobs checkpoint. - The deployed model serves inference through the API. See Call your model.
Next steps
- Save checkpoints: Turn on checkpointing and sync each checkpoint as your job writes it.
- Load a checkpoint into a new job: Resume training from a synced checkpoint.
- Training cache: Keep downloads and preprocessed data between jobs.
- Multi-node training: Train across nodes with high-speed InfiniBand networking.