How does batch size affect GPU memory consumption during training?

Quick Overview

Asks how the training batch size changes GPU memory use on a single GPU. Tests whether you can break training memory into its components, explain how each one responds to a larger batch and to larger inputs, and name the techniques for fitting a bigger effective batch along with what they cost.

How does batch size affect GPU memory consumption during training?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

You are training a neural network on one GPU and raising the batch size until memory runs out. How does batch size affect GPU memory consumption during training? ```hint Split the memory Separate what lives in GPU memory once per model from what exists once per training example in the batch, and ask which of the two the backward pass needs kept around. ``` ### What a Strong Answer Covers - Which parts of training memory do not depend on batch size, and roughly how large they are with Adam. - Why the activations saved for the backward pass grow with batch size and with input size. - A rough memory model, and what doubling the batch size does to the total. - Techniques that fit a larger effective batch, and what each one costs. ### Follow-up Questions - Training runs out of memory at batch size 64 but works at 32. How would you reach an effective batch of 256 on the same GPU? - How much memory does activation checkpointing save, and what does it cost in compute? - Why does `nvidia-smi` report more memory in use than your tensors account for? - How do sharded optimizers such as ZeRO reduce the part of memory that does not depend on batch size?

Overview: Asks how the training batch size changes GPU memory use on a single GPU. Tests whether you can break training memory into its components, explain how each one responds to a larger batch and to larger inputs, and name the techniques for fitting a bigger effective batch along with what they cost.

General logo
General
Nov 25, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

You are training a neural network on one GPU and raising the batch size until memory runs out.

How does batch size affect GPU memory consumption during training?

What a Strong Answer Covers Guidance

  • Which parts of training memory do not depend on batch size, and roughly how large they are with Adam.
  • Why the activations saved for the backward pass grow with batch size and with input size.
  • A rough memory model, and what doubling the batch size does to the total.
  • Techniques that fit a larger effective batch, and what each one costs.

Follow-up Questions Guidance

  • Training runs out of memory at batch size 64 but works at 32. How would you reach an effective batch of 256 on the same GPU?
  • How much memory does activation checkpointing save, and what does it cost in compute?
  • Why does nvidia-smi report more memory in use than your tensors account for?
  • How do sharded optimizers such as ZeRO reduce the part of memory that does not depend on batch size?