Learn / Lessons

How a GPU works

Here's a great story. How did a chip built for video games end up running AI? A game's world is built from triangles. The graphics card gets their corners.

Chapters

  1. 0:00Introduction
  2. 0:06Drawing a picture: From shapes to pixels
  3. 0:282006: From pixels to CUDA
  4. 0:422012: The AlexNet moment
  5. 1:04Why a GPU: A few fast, or thousands at once
  6. 1:18CUDA cores: 6,144 cores in a DGX Spark
  7. 1:36Tensor Cores: Built for matrix maths
  8. 1:46Why so fast: Many sums, all at once
  9. 2:11Language models: Memory sets the pace
  10. 2:25Wrap up
Read the transcript

Introduction

Here's a great story. How did a chip built for video games end up running AI?

Drawing a picture: From shapes to pixels

A game's world is built from triangles. The graphics card gets their corners. It works out which pixels each triangle covers, then the colour of every one. The colours go into memory, and the card sends them to the screen row by row. A 4K screen has over eight million pixels, often redrawn sixty times a second or more.

2006: From pixels to CUDA

Millions of pixels, all needing the same kinds of maths, again and again. In 2006, NVIDIA introduced CUDA. It let programmers use GPUs for other work, without going through graphics tools.

2012: The AlexNet moment

Now jump to 2012. Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton are teaching a neural network, AlexNet, to recognise pictures. Their kit? Two gaming graphics cards, running for five to six days. It beat the earlier methods by a wide margin, and became a turning point in AI's move to GPUs.

Why a GPU: A few fast, or thousands at once

So what's the secret? Think of your processor as a few experts, each very quick and versatile. A GPU is more like a huge crowd. Each one is slower, but thousands work at the same time.

CUDA cores: 6,144 cores in a DGX Spark

Meet the crowd inside a DGX Spark: 6,144 CUDA cores. Your program splits its work into threads, and they march in teams of 32, called warps. Everyone in a team does the same step on different data, and lots of teams are on the go at once.

Tensor Cores: Built for matrix maths

Now, AI absolutely loves multiplying grids of numbers. So Tensor Cores multiply two small blocks, and add a third, all in one go.

Why so fast: Many sums, all at once

Why is it so fast? Each number in the answer is one row times one column. No answer waits for another, so huge numbers of them are worked out at once. Tensor Cores take a whole small block per instruction. Shorter number formats fit more in, with less precision. And when two big grids meet, good software uses each fetched number many times, so there's less waiting on memory.

Language models: Memory sets the pace

Ask a language model a question, and it reads your words together, all at once. Then it answers one token at a time, fetching lots of data from memory for each. That's why memory speed often sets the pace.

Wrap up

Same maths, mountains of data. That's how a games chip became an AI chip.

Sources

More lessons