Estimate AI Workload Compute Cost & Energy
In this article
This guide shows you how to estimate the compute cost and energy needs of an AI workload before you run it. You’ll learn the key factors—hardware, runtime, utilization, and electricity price—and get a step-by-step method to produce a realistic budget and carbon footprint estimate.
What You'll Need
- Details about your AI workload: model type (e.g., transformer, CNN), training or inference, batch size, and expected runtime.
- Hardware specs: GPU model, number of GPUs, and their thermal design power (TDP) in watts.
- Cloud pricing or on-premises electricity rate (per kWh).
- A stopwatch or logging to measure actual runtime (if you already ran a small test).
Step-by-Step
- Determine the total compute time. Estimate the number of GPU-hours (or TPU-hours) your workload will consume. For training, this is roughly: number of steps × time per step. For inference, it’s number of requests × latency per request. If you have a small test run, scale up proportionally.
- Identify the hardware and its power draw. Look up the TDP of your GPU (e.g., A100 = 400W, H100 = 700W, RTX 4090 = 450W). For a full server, add CPU, memory, and cooling overhead—typically 1.3× to 1.5× the GPU TDP.
- Calculate energy consumption. Use the formula: Energy (kWh) = Total GPU-hours × Power draw (kW) × Utilization factor. The utilization factor accounts for the fact that GPUs don’t run at 100% power all the time. For training, use 0.8–0.9; for inference, 0.3–0.6.
- Compute the energy cost. Multiply the energy (kWh) by your electricity rate (per kWh). If using cloud, skip this and use the cloud provider’s per-GPU-hour price instead.
- Compute the cloud compute cost. If using a cloud provider, multiply the number of GPU-hours by the price per GPU-hour. Add storage and data transfer costs if significant.
- Add overhead for cooling and idle time. For on-premises, add 10–20% for cooling and power distribution losses. For cloud, this is already included in the price.
- Estimate the carbon footprint (optional). Multiply the energy (kWh) by your grid’s carbon intensity (kg CO₂ per kWh). Use a regional average (e.g., 0.4 kg/kWh in the US, 0.2 in Europe) or a more precise number from your utility.
- Validate with a small run. Run a small fraction of your workload (e.g., 1% of data) and measure actual time and power draw (using nvidia-smi or cloud monitoring). Scale up to get a better estimate.
Common Mistakes
- Using TDP as actual power draw. TDP is a maximum, not the average. Always apply a utilization factor.
- Ignoring the rest of the system. CPU, RAM, and storage also consume power. Add a 20–30% overhead for a full server.
- Mixing units. Keep watts vs. kilowatts straight. Convert everything to kW before multiplying by hours.
- Forgetting that training time scales with data and epochs. Doubling data or epochs doubles the time (roughly).
- Using peak cloud prices. Spot instances can be 60–70% cheaper but are interruptible. Use the right price for your use case.
Tips
- Use a power meter or cloud monitoring to get real numbers for your specific hardware.
- For large workloads, use a preliminary run on a single GPU to estimate total time and power, then scale.
- Consider using mixed precision (FP16) to reduce both time and energy.
- If you’re on a cloud, check if the provider offers a carbon footprint tool.
- For training, use early stopping and efficient data pipelines to reduce wasted compute.
Troubleshooting
My estimate is way off from the actual cost. Check the utilization factor—you may be overestimating. Run a longer test (e.g., 10 minutes) and measure real power with nvidia-smi or cloud metrics.
I don’t know the runtime in advance. Use a small sample to extrapolate. For example, if 1000 steps take 5 minutes, then 100,000 steps take 500 minutes.
Cloud price varies by region. Use the price for the region where you plan to run. Prices can differ by 20% or more.
My GPU doesn’t have a listed TDP. Search for the model’s TDP or measure it under load. If you can’t find it, assume 250W for a typical data-center GPU.
Frequently Asked Questions
What is a GPU-hour?
A GPU-hour is one GPU running for one hour. If you use 8 GPUs for 2 hours, that’s 16 GPU-hours.
How do I estimate training time for a new model?
Run a small number of steps (e.g., 100) on one GPU, measure the time, then multiply by the total steps and adjust for the number of GPUs (though scaling is not perfectly linear).
Does inference cost less than training?
Usually yes, because inference runs for a short time per request. But at high volume, inference can be significant.
What is a typical utilization factor?
For training, 0.8–0.9 is common. For inference, it varies widely—from 0.1 for sporadic requests to 0.9 for constant load.
Should I include data storage in the cost?
Yes, if you are storing large datasets or model checkpoints. Cloud storage costs are usually per GB per month.
How can I reduce energy consumption?
Use efficient hardware (e.g., newer GPUs), mixed precision, and consider using a cloud provider that uses renewable energy.