Compute, Memory and Performance

2 min

Objective: reason about cost before making the model bigger.

Time does not depend only on parameter count: activation size, sequence length, batch, operations and memory transfers also count. During training, you must store weights, gradients, optimizer states and activations needed for the backward pass.

Useful GPU, idle GPU

A GPU speeds up parallel computations that are large enough. Small batches, slow data loading or repeated CPU↔GPU transfers can leave it idle.

python
loader = DataLoader(dataset, batch_size=128, shuffle=True,
                    num_workers=4, pin_memory=True)

Measure before optimizing. On Windows, the optimal number of workers depends on the machine and the entry point must be protected with if __name__ == "__main__":.

Preview — the rest of the lesson is for enrolled readers.

Already enrolled with a code?

Your access is tied to your account, not to this link. Sign in with the same email you used in class: your course is waiting, no need to enter the code again.

Sign inNo account yet? Create one
This lesson is part of the “From Model to System” module

The first modules of the course are open to everyone. For the rest you have three options: buy this course once and for all, subscribe, or enter the code handed out in class.

Are you a student on this course?

The code is tied to your account: sign in or create an account and it will be applied automatically when you come back.

No account yet? Create one