Search
Course outline
  1. 01How a computer works
    1. 1.1What is a computer?(completed)
    2. 1.2The CPU: the brain(completed)
    3. 1.3Memory: RAM vs storage(completed)
    4. 1.4How the CPU and memory work together(completed)
    5. 1.5What happens when you turn on a computer(completed)
  2. 02How the Internet works
    1. 2.1What is the Internet?(completed)
    2. 2.2Addresses and names: IP and DNS(completed)
    3. 2.3Packets: how information travels(completed)
    4. 2.4Client and server: opening a website(completed)
    5. 2.5Inside a busy server(completed)
    6. 2.6Why this matters for AI(completed)
  3. 03Introducing the GPU
    1. 3.1What is a GPU?(completed)
    2. 3.2CPU vs GPU(completed)
    3. 3.3The GPU's own memory: VRAM(completed)
    4. 3.4How the CPU and GPU work together(completed)
    5. 3.5Why GPUs suit AI(completed)
  4. 04Tensors and models
    1. 4.1What is a tensor?soon
    2. 4.2What is an AI model?soon
    3. 4.3Training vs inferencesoon
  5. 05Splitting work across GPUs
    1. 5.1Why split work across GPUs?soon
    2. 5.2Data parallelismsoon
    3. 5.3Tensor parallelismsoon
    4. 5.4Pipeline parallelismsoon
    5. 5.5Expert parallelismsoon
    6. 5.6Which to use whensoon
  6. 06Serving LLMs with vLLM
    1. 6.1What is LLM serving?soon
    2. 6.2Meet vLLMsoon
    3. 6.3Serving a model with vLLMsoon

Lesson 3.3

The GPU's own memory: VRAM

Why the GPU has its own memory, why its size and speed matter, and how data gets there.

beginner 4 min readChecked

In one line

A separate GPU has its own memory, called VRAM, right next to its workers; data must be copied there from RAM first, and how much fits and how fast it flows decide how much work the GPU can do.

Real-life analogy

In Module 1, the head chef worked from the counter (RAM). Now our team of helpers works in a separate prep room with its own big table. That table is VRAM.

The helpers can only work on what is on their table. So before they start, someone must carry the ingredients from the main counter, through the doorway, onto the prep-room table.

  • If the table is too small, the job does not fit.
  • If ingredients cannot reach the helpers fast enough, the helpers stand around waiting.
  • If you keep carrying things back and forth through the doorway, everything slows down.

Where the comparison stops working: carrying food takes seconds. Copying data is much faster than that, but compared with how fast GPU workers calculate, the trip from RAM to VRAM is still slow. That is why good AI systems put data on the GPU once and keep it there.

Diagram

HOST: THE CPU SIDECPURAMDEVICE: THE GPU SIDEGPU coresVRAM (GPU memory)copy over theconnection (PCIe)The GPU works fastest on data that is already in its own VRAM.Getting it there means copying it from RAM, over the connection.
The CPU has RAM; the GPU has its own VRAM. Data is copied from RAM to VRAM over a connection such as PCIe.

Step by step

A GPU can have a huge number of workers. But workers are useless if they have nothing to work on. Where does a GPU keep its data?

Two sides, two memories

In a computer with a separate GPU (for example a graphics card, or a GPU in a server), there are two sides:

  • the host: the CPU and its memory, RAM;
  • the device: the GPU and its own memory, VRAM (video RAM, often just called GPU memory).

RAM and VRAM are separate memories, each attached to its own chip.

Why give the GPU its own memory?

Remember: a GPU has a huge number of workers, all hungry for numbers at the same moment. To keep them busy, it needs memory that can deliver a lot of data every second.

So GPUs come with high-bandwidth memory attached right next to them. Bandwidth means how much data can flow per second, like the width of a road.

How data gets to the GPU

When a program wants the GPU to work on something:

  1. The data starts in storage, and the CPU loads it into RAM (just like in Module 1).
  2. The CPU copies it from RAM into VRAM, across the connection between them (commonly PCIe; some systems use faster links such as NVLink).
  3. The GPU’s workers now read and write VRAM directly, very quickly.
  4. When the work is done, results can be copied back to RAM.

That trip across the connection is much slower than the GPU working inside its own memory. So a well-built program copies data over once and keeps it on the GPU as long as possible.

Why size matters

VRAM size decides what fits on the GPU.

For AI, the biggest thing to fit is usually the model itself, which is a huge collection of numbers (Module 4). On top of that, every request being answered needs some working space too, just like each request needed a little RAM in lesson 2.5.

If it does not fit, you run out of memory. The usual fixes are to split the model across several GPUs (Module 5) or to shrink the model so it needs less memory.

Why speed matters

VRAM speed (bandwidth) decides how fast the workers can be fed.

Many AI steps do only a little maths for each number they read. For those steps, the GPU spends much of its time waiting for data, not calculating. A faster memory means less waiting.

Key takeaways

  • A separate GPU has its own memory, VRAM, apart from the CPU’s RAM.
  • Data is copied from RAM to VRAM over a connection such as PCIe; that trip is relatively slow, so do it once.
  • VRAM size decides what fits (for AI: the model plus working space).
  • VRAM speed (bandwidth) decides how fast the workers can be fed.

Recap: the helpers have their own prep table. Carry the ingredients in once, make sure the table is big enough, and keep the supplies flowing fast.

Now you understand what VRAM is and why AI people talk about “GPU memory” so much. Next, we will see how the CPU and GPU work together as a team.

Quick check

Pick an answer, then press Check answer. Nothing is recorded.

  1. Where does the GPU keep the data it is working on?
  2. Before the GPU can work on data that is in RAM, what usually has to happen?
  3. An AI model is bigger than the VRAM on one GPU. What is a common solution?

Sources

This lesson was checked against these pages.

  1. 1.2. Programming Model (CUDA Programming Guide) · NVIDIA
  2. GPU Performance Background User's Guide · NVIDIA
  3. Conserving Memory · vLLM