Skip to content

Commit d41c61a

Browse files
add memory_timeline
1 parent 31a7205 commit d41c61a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

recipes_source/recipes/profiler_recipe.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
# 5. Using tracing functionality
3636
# 6. Examining stack traces
3737
# 7. Using profiler to analyze long-running jobs
38+
# 8. Memory Timeline Visualization
3839
#
3940
# 1. Import all necessary libraries
4041
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -453,6 +454,16 @@ def trace_handler(p):
453454
model(inputs)
454455
p.step()
455456

457+
######################################################################
458+
# Memory Timeline Visualization
459+
with profile(activities=[ProfilerActivity.CPU],
460+
profile_memory=True, record_shapes=True, with_stack=True) as prof:
461+
model(inputs)
462+
463+
# Add the memory timeline export right after:
464+
prof.export_memory_timeline("memory_timeline.html")
465+
466+
456467
######################################################################
457468
# Learn More
458469
# ----------

0 commit comments

Comments
 (0)