SEE: https://github.com/dougallj/applegpu
with profile(
activities=[
ProfilerActivity.CPU,
],
) as prof:
# Do the thing
print(prof.key_averages())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
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 flamegraphflamegraph.pl \
--title 'CPU time' \
--countname 'us.' \
./stacks.txt > stacks.svgPYTORCH_MPS_LOG_PROFILE_INFO=31 ./test.py