AI Learning Courses
AI Learning Courses › Tutorials › Tutorial 17
AI TUTORIAL 17 · 8 MIN READ

CPU vs GPU vs TPU: what is the difference, and why does AI need GPUs?

Everyone says AI runs on GPUs, and Google talks about TPUs. Learn what a CPU, a GPU and a TPU are, how they differ inside, why AI maths loves GPUs and TPUs, where the NPU in your phone fits, and try a CPU vs GPU speed test free in Google Colab.

Turn on JavaScript to watch the animated lesson. The full tutorial text is below.

The short answer Watch

A CPU has a few big cores, a GPU has thousands of small cores, and a TPU is one large grid built for matrix maths.
A CPU has a few big cores, a GPU has thousands of small cores, and a TPU is one large grid built for matrix maths.

A kitchen example Watch

Think of a big Indian wedding kitchen. The CPU is the head chef: brilliant, can cook any dish, plan the menu and handle surprises, but has only two hands. The GPU is a team of a thousand helpers, each only rolling rotis, but all at once, so ten thousand rotis are ready in minutes. The TPU is a roti-making machine: it cannot cook dal or plan the menu, but for rotis it is the fastest of all.

What is a CPU? Watch

The CPU runs your operating system (Windows, Android, iOS), opens apps, checks passwords and makes decisions. A laptop CPU usually has between 4 and 24 cores; big server CPUs have around a hundred. Each core is very fast and smart, and can jump between very different tasks.

Weak point: it does work mostly one step after another. For AI, which needs billions of small sums, a few cores are not enough.

What is a GPU? Watch

A GPU was made to draw video game pictures. A screen has millions of pixels, and each one needs a similar small calculation, so a GPU has thousands of small cores working in parallel (at the same time). For example, the NVIDIA RTX 4090 gaming card has more than 16,000 cores.

Around 2012, researchers found that the maths of neural networks is the same kind of work: huge numbers of multiply-and-add steps that can all happen at once. AlexNet, the model that started the deep learning boom, was trained on two gaming GPUs. Today, NVIDIA GPUs such as the H100 train and run most AI models, helped by NVIDIA's CUDA software.

What is a TPU? Watch

Google built its own AI chip, the Tensor Processing Unit. It started using TPUs inside its data centres in 2015 and announced them in 2016. A "tensor" is just a grid of numbers. A TPU is an ASIC, a chip made for one job: its heart is a large grid of multiply-add cells, and numbers flow through it like water through pipes.

It cannot run Windows or a game, but for AI maths it is extremely fast and saves power. Google uses TPUs for Search, YouTube recommendations and its Gemini models, and rents them to others through Google Cloud. You can only use a TPU through Google's cloud; you cannot buy one for your PC.

Why AI maths needs so many cores Watch

Remember the AI neuron: multiply each input by a weight, then add. A big model does this billions of times for every word it writes. Each sum is easy; the trouble is the number of them. Ten thousand simple cores working together beat ten genius cores working one by one.

CPU vs GPU vs TPU in one table Watch

CPUGPUTPU
Full nameCentral Processing UnitGraphics Processing UnitTensor Processing Unit
Coresa few, very powerfulthousands, small and simplebig grids of multiply-add cells
Worksstep by step, any taskmany small tasks at onceonly AI matrix maths
Made byIntel, AMD, Apple, Qualcomm, MediaTekNVIDIA, AMD, IntelGoogle only
AI usesmall models, data loadingtraining and running most AIGoogle's AI, cloud customers
Where you find itevery phone and laptopgaming PCs, AI serversGoogle Cloud data centres

And the NPU in your phone? Watch

New phones and laptops also have an NPU (Neural Processing Unit), a small AI chip like a pocket TPU. Apple calls its version the Neural Engine. It runs small AI jobs on the device itself: face unlock, photo touch-ups, live captions and voice typing, without draining the battery or sending your data to the cloud.

Training vs using: which chip does what Watch

Try it yourself, free Watch

Open Google Colab (colab.research.google.com), sign in, then choose Runtime, Change runtime type, and pick a T4 GPU. Free GPUs and TPUs depend on availability and have time limits. Paste this code, which multiplies two big grids of numbers on the CPU and then on the GPU:

import time, torch

x = torch.rand(4000, 4000)
start = time.time(); x @ x
print('CPU:', round(time.time() - start, 3), 'seconds')

g = x.cuda(); g @ g; torch.cuda.synchronize()   # warm up the GPU
start = time.time(); g @ g; torch.cuda.synchronize()
print('GPU:', round(time.time() - start, 3), 'seconds')

Run it. The GPU usually finishes many times faster than the CPU. That gap is why AI companies buy GPUs by the thousand.

Lesson learned Watch

A CPU has a few smart cores for any task, a GPU has thousands of simple cores doing sums at the same time, and a TPU is Google's chip built only for AI maths. AI needs billions of small sums, so GPUs and TPUs do the heavy work while the CPU manages.

Frequently asked questions

What is the main difference between a CPU and a GPU?

A CPU has a few powerful cores that do tasks one after another; a GPU has thousands of simpler cores that do many small calculations at the same time.

Why is a GPU used for AI?

Neural networks need billions of multiply-and-add steps that can run at the same time. A GPU's thousands of cores do them in parallel, so training is much faster than on a CPU.

What is a TPU?

A Tensor Processing Unit is a chip Google designed only for AI maths. Google uses it for its own AI and rents it through Google Cloud.

Is a TPU better than a GPU?

For large AI jobs built for it, a TPU can be faster and use less power. A GPU is more flexible: it also runs games and graphics and works with most AI software.

Do I need a GPU to use ChatGPT?

No. Chatbots run on the company's GPUs or TPUs in the cloud. You only need a GPU to train or run AI models on your own computer, and Google Colab gives a free one to learn with.