Programming
We provide developers and engineers the guides and tutorials they...
Search
We provide developers and engineers the guides and tutorials they...
Content is king. It's not just about how you're going to write, b...
Looking for an engaging connection with thousands of other people...
Why AI training needs GPUs: matrix maths, massive parallelism, memory limits, how training spreads across thousands of chips, and why inference differs.
Quick answer: Training a neural network consists almost entirely of one kind of arithmetic: multiplying and adding enormous grids of numbers. Each of those calculations is simple and independent of the others, so they can all be done at once. A CPU has a small number of powerful cores designed to do complicated tasks one after another. A GPU has thousands of simple cores designed to do the same operation on many numbers simultaneously, which is exactly what this workload needs. Modern models have billions of parameters and are trained on trillions of words, so even with GPUs the job takes thousands of chips running for weeks.
Also Read: How Recommendation Systems Know What You Want - How To's
A neural network is layers of numbers called weights. Running data through a layer is a matrix multiplication: a grid of inputs times a grid of weights.
Training repeats three stages, described in how neural networks learn:
All three are matrix arithmetic. A large language model has billions of weights, and one training step touches every one of them for every piece of input. Training involves an immense number of such steps.
| CPU | GPU | |
|---|---|---|
| Cores | A few to a few dozen, each powerful | Thousands, each simple |
| Designed for | Varied, branching, sequential logic | One operation applied to masses of data |
| Strength | Flexibility, single-thread speed | Throughput on parallel arithmetic |
| Analogy | A handful of expert chefs | A vast kitchen of line cooks all chopping at once |
When you multiply two matrices, every element of the result is its own small calculation, independent of all the others. Nothing needs to wait. A CPU works through them a few at a time. A GPU does thousands at once.
For neural network workloads, that translates into speed-ups of tens to hundreds of times.
A graphics processing unit was built to render video games. Drawing a frame means computing the colour of millions of pixels and transforming millions of triangle corners, using the same matrix maths, all independently, sixty times a second. Chip makers spent decades building hardware that does huge amounts of simple arithmetic in parallel.
Researchers noticed that neural networks needed the same thing. Two developments made it practical:
Software frameworks such as PyTorch and TensorFlow then made GPU training routine.
Earlier language models read text one word at a time, which limited how much could be done in parallel. The transformer architecture, introduced in Attention Is All You Need, processes all positions of a sequence at once. That fits GPUs perfectly, and it made it worthwhile to train on vastly more data with vastly more hardware. See transformers explained.
Billions to hundreds of billions of weights. Every training step reads and updates all of them.
Large language models are trained on trillions of tokens of text. Image and video models consume enormous media collections.
A GPU has its own memory, called VRAM, and during training it must hold:
A model with tens of billions of parameters needs far more memory than any single GPU has. It must be spread across many.
Also Read: Overfitting Explained: Memorising Instead of Learning
Even if one GPU could hold the model, training on it would take lifetimes. Using thousands in parallel brings that down to weeks.
Adding GPUs does not give a proportional speed-up, because coordination has a cost. Much of the engineering in large-scale training is about keeping every chip busy.
GPUs dominate, but they are not the only accelerators:
Training creates the model. Inference is using it to answer requests.
| Training | Inference | |
|---|---|---|
| What happens | Forward and backward passes, weight updates | Forward pass only |
| Memory | Weights, gradients, optimiser state, activations | Mostly just weights |
| Scale | Thousands of GPUs for weeks, once per model | From a single chip per request, repeated for every user |
| Can run on smaller hardware | No | Often, especially with compressed models |
Inference is far lighter per request. A model that took a data centre to train may run on one GPU, and small or quantised models run on a laptop or phone. But inference happens constantly, for every user, so across a popular product's lifetime its total computing cost can exceed that of training.
Large GPU clusters draw enormous amounts of electricity and produce a great deal of heat, so data centres need substantial power supplies and cooling. Demand for AI chips has repeatedly outrun supply. These physical limits, on chips, energy and construction, now shape the pace of AI development as much as algorithms do.
Neural networks need the same simple arithmetic done on huge numbers of values at once. GPUs have thousands of cores built for exactly that; CPUs have a few cores built for sequential, varied work.
Yes, for small models. For large ones it would take impractically long.
The GPU's own memory. The model's weights and the intermediate values of training must fit in it, so it limits how large a model and batch one GPU can handle.
Models have billions of parameters and are trained on vast datasets. One chip has neither the memory nor the speed, so the work is divided across thousands.
AI training is matrix arithmetic at an almost unimaginable scale, and that arithmetic happens to be perfectly parallel. GPUs, built to paint millions of pixels at once, turned out to be the right tool. The number of chips needed is a direct consequence of model size, data size and the wish to finish in weeks instead of centuries.