Topic 6 of 6 · 5 min read
Renting GPUs and budgeting runs
Goal: Build a cost plan for a fine-tuning run with GPU type, hours, storage and a stop condition.
Decide the budget and stop condition before the run starts, then rent the cheapest GPU that fits the memory estimate.
Check yourself · 1 of 3
How should you estimate the hours a fine-tuning run will take?
Why it matters
GPU rental is billed by the hour whether the job is learning or crashed. A forgotten instance, a loop of failed restarts or a run that was never going to finish can cost more than the whole project was worth.
The options
- Large clouds (AWS, Google Cloud, Azure). Most services, quotas and approvals, and usually the highest on-demand prices. Good if your data and security are already there.
- GPU specialists (such as RunPod, Lambda, Vast.ai). Simpler, often cheaper per hour, with less managed infrastructure around the GPU. Prices and availability change, so check the current price page when planning.
- Serverless fine-tuning from model providers or platforms. You upload data and pay per training token or per job, with no GPUs to manage. Less control over the recipe.
- Spot or interruptible instances. Often much cheaper, but can be taken away with little notice. Only use them with frequent checkpoints on external storage.
How to build a cost plan
- Pick the GPU from the memory estimate, not from habit. A LoRA run that fits on 24 GB should not rent an 80 GB card.
- Estimate hours. Run 50 steps, measure tokens per second, then compute: total tokens divided by tokens per second.
- Add the other bills: disk for datasets and checkpoints, data transfer out, and idle time while you set up.
- Add a margin for at least one failed attempt, commonly 30 to 50 percent.
- Set a stop condition: a hard dollar cap or hour limit, a billing alert, and an automatic shutdown at the end of the script.
python train.py && sudo shutdown -h now
Before and after
Weak plan: "Rent an 8 x H100 server and see how long it takes." No estimate, no cap, no checkpoints. Fixed plan: "LoRA on 1 x 48 GB GPU, 6 hours measured from a 50-step test, 100 GB disk, 40 percent margin, hard cap at 12 GPU-hours, alert at 80 percent, shutdown after the final checkpoint upload."
What goes wrong
- The forgotten instance. The job finished, the machine kept billing.
- Paying for idle setup. Downloading a 100 GB model on a rented GPU is billed time. Prepare data and weights first.
- Spot without checkpoints. The instance is reclaimed and all progress is lost.
Examples
A cost plan
Goal: LoRA fine-tune of a 7B model on 20M tokens
GPU: 1 x 48 GB (fits per memory estimate)
Measured: 50 steps at 2,400 tokens/s => 20M tokens in about 2.3 h per epoch
Plan: 3 epochs, about 7 h; with 40% margin, 10 h
Other: 150 GB disk, checkpoint upload to object storage
Cap: 12 GPU-hours, billing alert at 80%, shutdown on finish
The expensive weekend
A run crashes at 2 a.m. Friday with an out-of-memory error. The instance keeps billing until Monday. The fix is a wrapper that shuts the machine down when the script exits, plus a billing alert that emails at a set amount.
Key points
- Choose the GPU from the memory estimate, then check current prices, since they change often.
- Measure tokens per second on a 50-step test and compute hours from it, rather than guessing.
- Budget disk, transfer and setup time as well as GPU hours, and add a margin for a failed attempt.
- Spot instances are cheaper but need frequent checkpoints saved to storage that survives the machine.
- Set a hard cap, a billing alert and an automatic shutdown before the run begins.
Common mistakes
- Renting by habit, such as an 80 GB card for a job that fits in 24 GB.
- Skipping the short measurement run and guessing the hours.
- Forgetting disk, egress and idle setup time in the estimate.
- Leaving the instance running after the script ends, with no shutdown or billing alert.
Check yourself · 2 of 3
When are spot or interruptible GPU instances a reasonable choice?
Check yourself · 3 of 3
Which item belongs in a budget before a rented GPU run starts?
Practice items, not counted towards your mastery.
Start here
- The Ultra-Scale Playbook: Training LLMs on GPU Clusters (opens in a new tab)BookFree
An interactive guide to data, tensor, pipeline and ZeRO parallelism with measured trade-offs.
- Getting Started with Fully Sharded Data Parallel (FSDP) (opens in a new tab)DocsFree
A runnable FSDP setup that shows how parameters, gradients and optimizer state are sharded.
- ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (opens in a new tab)PaperFree
Breaks down the bytes per parameter for weights, gradients and Adam states, and how sharding removes the copies.
More for this topic
- Hugging Face Accelerate documentation (opens in a new tab)DocsFree
One launcher for multi-GPU, mixed precision and gradient accumulation without rewriting the loop.