TLDRocket
Sign in

Tools & Coding

975 summarised stories in Tools & Coding, each linking back to the original source. Browse all topics →

Tuesday, 24 December 2024

Visualize and understand GPU memory in PyTorch

Hugging Face 1 year ago 26

PyTorch provides a built-in tool (`torch.cuda.memory._record_memory_history()`) that generates visual profiles of GPU memory usage during model training. The memory profile for a 1.5B parameter model training loop shows three distinct spikes, each corresponding to a training iteration with peaks occurring during forward passes, backward passes, and optimizer steps. Total GPU memory required equals model parameters plus optimizer state plus the maximum of either (gradients plus optimizer intermediates) or (activations), and can be estimated using formulas based on parameter count, batch size, and sequence length.

The daily briefing

Every AI story that matters, in your inbox by 8am.

TLDRocket reads all relevant sources, removes duplicate coverage, and summarises the day in two minutes. Follow companies and topics for alerts, or get the briefing in Slack. Free, no spam, unsubscribe anytime.