Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Estimate AI Model Hosting Cost in the Cloud

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide walks you through estimating the monthly cost of hosting an AI model in the cloud. You'll learn what factors drive the bill, how to calculate compute, storage, and data transfer costs, and how to compare pricing across major providers. Before you start, gather the model's size, expected request volume, and latency requirements.

What You'll Need

  • Model details: number of parameters (e.g., 7B, 70B), model architecture (dense vs. MoE), and precision (FP16, INT8, etc.)
  • Inference workload: expected requests per second (RPS), average tokens per request (input + output), and peak vs. average traffic
  • Hardware knowledge: whether you need GPUs (e.g., A100, H100) or can use CPUs for small models
  • Cloud provider pricing pages (or a calculator like the one below) for compute, storage, and egress
  • A rough idea of your storage needs (model weights, embeddings, logs) and data transfer volume

Step-by-Step

  1. Estimate the memory required for the model. Use the formula: Memory (GB) ≈ (Parameters × Bytes per Parameter) + Overhead. For FP16, bytes per parameter = 2; for INT8, it's 1. Add ~20-30% for activations and framework overhead. Example: a 7B model in FP16 needs about 14GB + ~4GB overhead = ~18GB.
  2. Choose the right GPU instance. Match the memory to available GPUs. For example, an A100 40GB can host a 7B model in FP16, while a 70B model needs multiple GPUs (e.g., 8×A100 80GB). List the hourly price of the instance from your provider's pricing page.
  3. Calculate compute cost for inference. Multiply the instance hourly rate by the number of hours you expect to run it. If you have variable traffic, consider auto-scaling: estimate the average number of instances running per hour. For example, 1 A100 at $2/hour for 730 hours = $1,460/month.
  4. Estimate request throughput. Check the model's tokens-per-second (TPS) on your chosen GPU. Divide the instance's TPS by your average tokens per request to get requests per second (RPS). If your required RPS exceeds that, you'll need multiple instances. Adjust the instance count accordingly.
  5. Add storage costs. Model weights, container images, and logs consume disk. Use block storage (e.g., EBS, persistent disk) for the model files. Estimate total GB and multiply by the monthly price per GB (typically $0.08-$0.20). For example, 100GB at $0.10/GB = $10/month.
  6. Add data transfer (egress) costs. Most providers charge for data leaving their network. Estimate monthly egress in GB: requests × average response size. Multiply by the per-GB egress rate (often $0.09-$0.15). If you serve traffic from the same region, keep egress low.
  7. Consider training/fine-tuning costs (if any). If you need to train or fine-tune, add separate compute hours. Training can be 10-100× more expensive than inference for the same model. Use the same hourly rates but estimate training duration.
  8. Sum everything and add buffer. Add 20-30% for monitoring, logging, load balancers, and unexpected spikes. This gives you a realistic monthly estimate.

Common Mistakes

  • Ignoring memory overhead: Only counting parameter memory, forgetting activations and framework overhead, leading to underestimating GPU requirements.
  • Using list prices without discounts: Cloud providers offer committed-use discounts (1-3 year terms) that can cut costs 30-60%. If you plan for steady load, factor those in.
  • Overlooking egress costs: Data transfer out can be a significant hidden cost, especially for high-traffic APIs.
  • Assuming linear scaling: Doubling the number of GPUs doesn't always double throughput due to communication overhead. Test or use provider benchmarks.
  • Forgetting about idle time: If you leave instances running 24/7 but only serve traffic during business hours, you're paying for idle compute. Use auto-scaling or serverless options.

Tips

  • Use spot instances for non-critical workloads: Spot/preemptible instances can be 60-90% cheaper, but they can be terminated. Good for batch inference or dev/test.
  • Optimize model size: Quantize to INT8 or INT4 to reduce memory and increase throughput. A 7B model in INT8 uses ~7GB, fitting on smaller, cheaper GPUs.
  • Leverage serverless inference: Services like AWS Lambda or Cloud Run (for lightweight models) can scale to zero, so you pay only per request. Good for spiky traffic.
  • Use a cost calculator: Most providers have pricing calculators. Input your instance type, hours, and storage to get a precise estimate.
  • Monitor and adjust: After launch, track actual usage with cloud monitoring. Adjust instance sizes or scaling policies to match real traffic.

Troubleshooting

If your estimate seems too high or low, check the following:

  • Recheck GPU memory: Use the formula again. If the model doesn't fit, you may need a larger GPU or to quantize.
  • Verify throughput numbers: Look up benchmarks for your exact GPU and model. If your RPS is unrealistic, adjust instance count.
  • Review egress assumptions: Estimate the average response size. If you're generating long outputs, egress can be higher than expected.
  • Check for hidden costs: Some providers charge for load balancers, NAT gateways, or VPC peering. Add those to your estimate.
  • Contact provider support: If you're unsure about pricing, ask for a custom quote or use their sales team to validate your estimate.

Frequently Asked Questions

How much does it cost to host a 7B parameter model?

Roughly $300-$1,500/month for inference on a single GPU (e.g., A10G or L4) running 24/7, plus storage and egress. Using spot or serverless can reduce this significantly.

What's the cheapest way to host an AI model?

Use a serverless or spot-based approach for spiky traffic, quantize the model to reduce GPU requirements, and use CPUs for very small models. Also consider managed services that auto-scale to zero.

How do I estimate tokens per second for my model?

Check provider benchmarks or run a quick load test. As a rough guide, a 7B model on an A100 can achieve ~1,500 tokens/sec; on a T4, ~300 tokens/sec. Adjust for batch size and input length.

Do I need to pay for training if I use a pretrained model?

No, if you use the model as-is. Only pay for fine-tuning if you need to adapt it. Fine-tuning costs are additional compute hours, often 10-50 hours on a single GPU.

How do cloud providers charge for GPU instances?

Per second or per hour, depending on the provider. Prices vary by region and instance type. Committed-use discounts lower the hourly rate but require a 1-3 year contract.

Can I use a CPU instead of a GPU?

For very small models (under 1B parameters) and low latency requirements, CPUs can work but are much slower. For most production LLMs, GPUs are necessary.