Skip to content

Latest commit

 

History

History
84 lines (60 loc) · 1.45 KB

File metadata and controls

84 lines (60 loc) · 1.45 KB

Apple Silicon

SEE: https://github.com/dougallj/applegpu

CPU Profiling

SEE: https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html#using-profiler-to-analyze-execution-time

with profile(
  activities=[
    ProfilerActivity.CPU,
  ],
) as prof:

  # Do the thing

print(prof.key_averages())

Trace

SEE: https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html#using-tracing-functionality

with profile(
  activities=[
    ProfilerActivity.CPU,
  ],
) as prof:

  # Do the thing

prof.export_chrome_trace('./trace.json')
chrome://tracing

Flame Graph

SEE: https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html#visualizing-data-as-a-flame-graph

with profile(
  activities=[
    ProfilerActivity.CPU,
  ],
  with_stack = True,

  # NOTE: Needed due to https://github.com/pytorch/pytorch/issues/100253
  experimental_config=torch._C._profiler._ExperimentalConfig(verbose=True)
) as prof:

  # Do the thing

prof.export_stacks('./stacks.txt', 'self_cpu_time_total')
brew install flamegraph
flamegraph.pl \
  --title 'CPU time' \
  --countname 'us.' \
  ./stacks.txt > stacks.svg

MPS Profiling

SEE: pytorch/pytorch#100635

PYTORCH_MPS_LOG_PROFILE_INFO=31 ./test.py