โฑ๏ธProfiling SLM Lab
Quick Start
# Use built-in profiling (recommended)
slm-lab run --profile slm_lab/spec/benchmark/ppo/ppo_cartpole.json ppo_cartpole train
# Let it run for a few minutes, then Ctrl+C to stop and save profile dataProfiling Methods
Method 1: Built-in --profile Flag
--profile Flagslm-lab run --profile spec.json spec_name trainMethod 2: Manual cProfile + snakeviz
# Install visualization tool
uv add snakeviz
# Profile a training run
uv run python -m cProfile -o ppo.prof -c "from slm_lab.main import main; main(['slm_lab/spec/benchmark/ppo/ppo_cartpole.json', 'ppo_cartpole', 'train'])"
# Run for desired duration, then Ctrl+C to collect data
# Visualize results (opens browser)
uv run snakeviz ppo.profMethod 3: Line-level Profiling
Reading Profile Results
snakeviz Visualization
What to Look For
Bottleneck
Likely Cause
Fix
Common Performance Patterns
CPU-bound (Classic Control, Box2D)
GPU-bound (Atari, large networks)
Monitoring Training Speed
Real-time FPS
Environment
Typical FPS (CPU)
Typical FPS (GPU)
Using glances for System Monitoring
Memory Profiling
RAM Usage by Algorithm
Algorithm
Memory Driver
Typical RAM
GPU VRAM Usage
Environment
Network
Batch Size
VRAM
Monitoring Memory
Tips for Faster Training
Last updated
Was this helpful?