From 31a72059e19d9b245774f80f8c883340b4eee3be Mon Sep 17 00:00:00 2001 From: Krishna Kalyan Date: Sat, 7 Jun 2025 13:12:31 +0000 Subject: [PATCH 1/2] add links --- recipes_source/recipes/profiler_recipe.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes_source/recipes/profiler_recipe.py b/recipes_source/recipes/profiler_recipe.py index 4d43726e71f..51688669e83 100644 --- a/recipes_source/recipes/profiler_recipe.py +++ b/recipes_source/recipes/profiler_recipe.py @@ -461,4 +461,5 @@ def trace_handler(p): # # - `PyTorch Benchmark `_ # - `Visualizing models, data, and training with TensorBoard `_ tutorial +# - `Understanding GPU Memory 1: Visualizing All Allocations over Time ` # From d41c61ae9247724ec1ee8b0e0f93db8ea91987c5 Mon Sep 17 00:00:00 2001 From: Krishna Kalyan Date: Sat, 7 Jun 2025 13:21:24 +0000 Subject: [PATCH 2/2] add memory_timeline --- recipes_source/recipes/profiler_recipe.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/recipes_source/recipes/profiler_recipe.py b/recipes_source/recipes/profiler_recipe.py index 51688669e83..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 # ----------