3.3.6 · D1Deep Learning Frameworks

Foundations — GPU acceleration and device management

2,153 words10 min readBack to topic

This page builds every symbol, word, and picture the parent note GPU acceleration and device management leans on. Read it top to bottom: nothing later uses a thing that wasn't drawn earlier.


1. What is a "number in a computer" and where does it live?

Before we can talk about moving numbers between a CPU and a GPU, we need to know that a number occupies physical space — it lives in a chip called memory.

Figure — GPU acceleration and device management

Look at the two coloured mailbox rows in the figure. A piece of data drawn in one room cannot be read by the worker in the other room — it must first be copied across the bridge in the middle. That bridge is the slow part we will meet later.


2. Bytes and float — how much space one number takes

Why we care: memory is finite. A tensor of a million numbers costs bytes MB. When the parent says "one GPU has ~24 GB", it means 24 billion bytes of mailboxes — enough for about 6 billion floats. This is why big models don't fit and why multi-GPU exists.


3. CPU vs GPU — the two kinds of worker

Figure — GPU acceleration and device management

The picture shows why the GPU wins on the right kind of job: 16 fast workers finishing tasks one-by-one, versus thousands of slower workers all finishing together. The GPU only wins when the job splits into thousands of independent pieces — which brings us to the next idea.


4. Why a neural network is the "right kind" of job

A neural network's heaviest work is matrix multiplication. We need to see exactly why that is "thousands of independent tiny sums".

The reason this matters: every entry of is computed independently of every other entry. Entry doesn't need to know . So if has, say, a million entries, that is a million independent multiply-add jobs — exactly what thousands of GPU cores devour in parallel.

Figure — GPU acceleration and device management

In the figure, the highlighted red row of and blue column of produce the one green entry of . Notice no other cell of needs that computation — this is the "embarrassingly parallel" property the parent note names.

The backward pass and the normalization steps are also built from these same matrix multiplies, which is why the whole pipeline benefits from the GPU.


5. The bridge between rooms — PCIe transfer

Because RAM and VRAM are separate rows of mailboxes (Section 1), moving a number from one to the other means copying it across a physical cable called PCIe.

Figure — GPU acceleration and device management

The figure shows the bandwidth gap as pipe widths: a narrow straw across the bridge, a fire-hose inside the GPU. This single mismatch is the whole reason for the parent's "Golden Rule": keep data on the GPU, cross the bridge as rarely as possible.


6. Symbols you'll meet in the formulas


7. How it all connects

Numbers live in memory RAM and VRAM

Two separate rooms need a bridge PCIe

Bytes and floats measure memory used

CPU few fast cores vs GPU many slow cores

GPU wins on parallel jobs

Matrix multiply is many independent multiply-adds

Model size limits one GPU

Golden Rule keep data on GPU

Multi GPU data parallelism

GPU acceleration and device management

Read it as: memory + the bridge + the CPU/GPU contrast + the matrix-multiply insight all feed into the topic. Nothing enters the parent note that wasn't drawn on this page.


Equipment checklist

Cover the right side of each line and try to answer before revealing.

  • Why can't a CPU read a number sitting in GPU memory directly? ::: Because RAM and VRAM are physically separate rows of mailboxes; the CPU has no address into VRAM — the data must be copied across the PCIe bridge first.
  • How many bytes does a standard float take, and how much memory do a million floats need? ::: 4 bytes each, so MB (using decimal MB = bytes).
  • Why do MB and MiB give slightly different numbers? ::: MB is decimal ( bytes) while MiB is binary ( bytes), so the same byte count is a smaller number of MiB.
  • In one sentence, why does a GPU beat a CPU on neural networks but not on all jobs? ::: A GPU has thousands of slow cores that only help when a job splits into thousands of independent pieces — matrix multiplication does exactly that, most everyday sequential code does not.
  • What does the notation mean? ::: is a matrix of real numbers with rows and columns.
  • Why is each entry of an independent job? ::: Each entry is a single dot product of one row of with one column of , and needs no other entry of to compute.
  • Why is the exact operation count , and why do we usually write ? ::: Each entry needs multiplications plus additions = operations; rounding up to (negligible for large ) gives the tidy .
  • What is bandwidth, and how does PCIe compare to GPU internal memory? ::: Bandwidth is data moved per second; PCIe is ~16 GB/s while GPU internal memory is ~900 GB/s, over 50× faster inside.
  • Why must you call synchronize before timing a GPU operation? ::: GPU work is asynchronous — the CPU fires the order and continues, so without a barrier the timer stops before the GPU actually finishes.
  • What do and stand for? ::: is the bundle of all the model's adjustable parameters; is the gradient, the direction to nudge to reduce the loss.
  • What is , in what units are its frequencies, and roughly what value did the parent's numbers give? ::: is the speedup ; both frequencies are in GHz so the units cancel, and the plug-in gave about 312× (ignoring transfer).