2bcloud earned the ๐—”๐—ช๐—ฆ ๐—ฆ๐—บ๐—ฎ๐—น๐—น & ๐— ๐—ฒ๐—ฑ๐—ถ๐˜‚๐—บ ๐—•๐˜‚๐˜€๐—ถ๐—ป๐—ฒ๐˜€๐˜€ ๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ฒ๐—ป๐—ฐ๐˜†.๐Ÿ†

GPUs on AWS: How to Run Complex Math Faster and Cheaper

December 5, 2024
Written by Evgeny Lukashov
AWS GPU instances vs x86 and Graviton

As cloud architects, weโ€™re all chasing the holy grail: performance and cost-efficiency. Whether youโ€™re running complex mathematical algorithms, AI workloads, or just trying to process massive datasets, the type of EC2 instance you choose can make or break your goals.

In recent months, more customers from industries like medical imaging and cybersecurity have been turning to GPU-powered EC2 instances to supercharge their computations. GPUs arenโ€™t just for gaming or AI anymoreโ€”theyโ€™re changing the game for mathematical workloads too.

So, we ran a simple test: How do x86, Graviton, and GPU-based instances compare when crunching the same mathematical function? The results might just make you rethink your instance strategy.

Benchmark Setup

To keep things fair, we set up three AWS EC2 instances in the Ireland region (a favorite for its competitive pricing and proximity to EU businesses):

The test? We ran the same computationally intense mathematical function on each instance, measuring execution time, monthly costs, and cost per 1000 jobs.

For context, hereโ€™s the raw monthly cost for 730 hours of usage (standard on-demand rates):

  • m7a.xlarge: $188.63
  • m7g.xlarge: $132.79
  • g5.xlarge: $819.79

Results: Performance and Cost Comparison
We compared three key metricsโ€”execution time, monthly costs, and cost per 1000 jobs. Hereโ€™s what we found:

  1. Execution Time

The g5.xlarge obliterated the competition, completing the task in just 16 seconds, while the m7a.xlarge and m7g.xlarge clocked in at 1148 seconds and 1100 seconds, respectively.

This means:

  • The Graviton instance (m7g.xlarge) is 4.36% faster than the x86 instance.
  • The GPU instance (g5.xlarge) is an astonishing 7075% faster than the x86 instance.

Translation: If speed matters, GPUs winโ€”hands down.

GPU VS CPU Execution Time
  1. Monthly Costs

Hereโ€™s where things get interesting. GPU instances are pricey at first glance, with the g5.xlarge costing 517% more than the Graviton instance. But this doesnโ€™t tell the whole story.

  1. Cost Per 1000 Jobs

When we calculate the cost per 1000 jobs, the story flips:

  • m7a.xlarge: $80 per 1000 jobs
  • m7g.xlarge: $65 per 1000 jobs
  • g5.xlarge: $10 per 1000 jobs

Thatโ€™s rightโ€”the GPU instance is 8x cheaper than Graviton and 15x cheaper than x86 when it comes to cost per job.

GPU VS CPU Cost Per 1000 Jobs

Visualizing the Results
To make it even clearer, here are the results in a table:

Instance TypeArchitectureMonthly CostExecution TimeCost/1000 Jobs
m7a.xlargex86$188.631148 seconds$80
m7g.xlargeGraviton$132.791100 seconds$65
g5.xlargeNVIDIA GPU$819.7916 seconds$10

Key Takeaways
So, what does this mean for your workloads?

  1. If Speed is Critical: Go for GPU instances. Theyโ€™re 7000% faster than standard x86 instances, and the cost per job makes the upfront cost worthwhile.
  2. For Budget-Conscious Workloads: Graviton (m7g.xlarge) offers decent performance at a lower cost than x86, making it great for steady, non-time-sensitive workloads.
  3. Avoid Sticker Shock: GPU instances look expensive at first glance, but their cost-effectiveness shines for high-throughput jobs. Bonus: Spot instances can slash costs even further.

When Should You Use GPU Instances?
GPU instances shine for workloads like:

  • AI/ML Training and Inference: TensorFlow, PyTorch, or anything CUDA-enabled runs beautifully here.
  • Complex Math and Analytics: Think Monte Carlo simulations or massive linear algebra problems.
  • Graphics Rendering: Ideal for gaming engines or 3D rendering pipelines.

For these use cases, investing in GPUs isnโ€™t just an optionโ€”itโ€™s a no-brainer.

Closing Thoughts

Choosing the right EC2 instance isnโ€™t just about raw costs; itโ€™s about aligning the instanceโ€™s capabilities with your workload needs. As this benchmark shows, GPUs arenโ€™t just fasterโ€”they can also be far more cost-effective for the right jobs.

AWS gives you the flexibility to choose, so next time youโ€™re evaluating instances, ask yourself: Is speed king for this workload? If the answer is yes, it might be time to give GPU cores a try.

Got questions about optimizing your AWS setup? Reach out to our teamโ€”weโ€™ve helped hundreds of companies find their perfect cloud stack.