Installation
Install the PyTorch profiler with optional dependencies:Quick start
Profile a function with the context profiler:Core profiler
TheGPUMemoryProfiler provides comprehensive memory profiling:
Initialize the profiler
Create a profiler instance with your desired configuration:For multi-GPU systems, specify the device:
Decorator-based profiling
Use the@profile_function decorator for automatic profiling:
Backend support
The profiler automatically detects your PyTorch backend:- CUDA/ROCm
- MPS (Apple Silicon)
- CPU mode
For NVIDIA or AMD GPUs:The profiler uses
torch.cuda APIs for memory tracking.Memory tracking
UseMemoryTracker for real-time monitoring with alerts:
Profiled modules
Wrap PyTorch modules to automatically profile forward passes:OOM flight recorder
Capture memory state when out-of-memory errors occur:Get system info
Check GPU availability and configuration:Next steps
CLI usage
Learn to use gpumemprof from the command line
Visualization
Generate plots and export profiling data
TUI dashboard
Use the interactive terminal dashboard
CPU mode
Profile CPU memory when GPU is unavailable