perf-memory-tuning

Reduce GPU peak memory usage during large-scale model training by adjusting parallelism and activation recompute strategies.

852|445|Updated May 21, 2025
One-click install
npx skills add https://github.com/NVIDIA-NeMo/Megatron-Bridge --skill perf-memory-tuning
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: perf-memory-tuning
Source: https://github.com/NVIDIA-NeMo/Megatron-Bridge/tree/main/skills/perf-memory-tuning
Command: npx skills add https://github.com/NVIDIA-NeMo/Megatron-Bridge --skill perf-memory-tuning

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires nvidia-pyindex, pycuda, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses GPU out-of-memory (OOM) failures caused by memory fragmentation and inefficient resource utilization during model training.

Core Features & Use Cases

  • Memory fragmentation mitigation through setting PYTORCH_CUDA_ALLOC_CONF to expandable segments.
  • Parallelism adjustment techniques such as increasing tensor parallelism or pipeline parallelism to fit models within GPU memory constraints.
  • Activation recompute strategies to reduce peak memory consumption.
  • Use Case: When training large language models on H100 GPUs, users can prevent OOM errors by applying these techniques, ensuring stable training without hardware upgrades.

Quick Start

Set the environment variable PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True before launching your training session to dramatically reduce memory fragmentation and eliminate OOM errors.

Frequently Asked Questions about perf-memory-tuning

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix CUDA out-of-memory errors caused by memory fragmentation during model training?

Fix CUDA out-of-memory errors by setting the environment variable PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True before launching training to reduce memory fragmentation and eliminate OOM failures.

What's the best way to reduce GPU peak memory usage when training large models on H100 GPUs?

Reduce GPU peak memory by applying activation recompute strategies, resizing tensor parallelism or pipeline parallelism, and enabling expandable segments to fit large models within memory constraints.

Does adjusting tensor parallelism and pipeline parallelism help prevent OOM errors on high-end GPU clusters?

Adjusting parallelism helps prevent OOM errors by resizing tensor parallelism or pipeline parallelism to fit models within GPU memory constraints, ensuring stable training on high-end GPU clusters.

How does activation recompute work to reduce peak memory consumption during large-scale model training?

Activation recompute reduces peak memory consumption by strategically recomputing activations during the backward pass, freeing up memory for large-scale model training without requiring hardware upgrades.

When do I need to configure expandable segments for GPU memory management?

Configure expandable segments when experiencing GPU out-of-memory failures caused by memory fragmentation, as it maintains training stability and ensures compatibility with various parallelism configurations.

Do I need pycuda to optimize GPU memory use and troubleshoot OOM errors?

Optimizing GPU memory requires pycuda and nvidia-pyindex dependencies to support troubleshooting OOMs, managing activation memory, and maintaining training stability across parallelism configurations.