diff --git a/recipes_source/recipes/profiler_recipe.py b/recipes_source/recipes/profiler_recipe.py index 4d43726e71f..ff71562fd55 100644 --- a/recipes_source/recipes/profiler_recipe.py +++ b/recipes_source/recipes/profiler_recipe.py @@ -35,6 +35,7 @@ # 5. Using tracing functionality # 6. Examining stack traces # 7. Using profiler to analyze long-running jobs +# 8. Memory Timeline Visualization # # 1. Import all necessary libraries # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -453,6 +454,16 @@ def trace_handler(p): model(inputs) p.step() +###################################################################### +# Memory Timeline Visualization +with profile(activities=[ProfilerActivity.CPU], + profile_memory=True, record_shapes=True, with_stack=True) as prof: + model(inputs) + +# Add the memory timeline export right after: +prof.export_memory_timeline("memory_timeline.html") + + ###################################################################### # Learn More # ---------- @@ -461,4 +472,5 @@ def trace_handler(p): # # - `PyTorch Benchmark `_ # - `Visualizing models, data, and training with TensorBoard `_ tutorial +# - `Understanding GPU Memory 1: Visualizing All Allocations over Time ` #