Skip to content

Commit 80f8332

Browse files
committed
Update with the help of Ilia
1 parent 5bc90f1 commit 80f8332

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

intermediate_source/tensorboard_profiler_tutorial.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
"""
22
PyTorch Profiler With TensorBoard
33
====================================
4-
This recipe demonstrates how to use PyTorch Profiler
4+
This tutorial demonstrates how to use TensorBoard plugin with PyTorch Profiler
55
to detect performance bottlenecks of the model.
66
7-
.. note::
8-
PyTorch 1.8 introduces the new API that will replace the older profiler API
9-
in the future releases. Check the new API at `this page <https://pytorch.org/docs/master/profiler.html>`__.
10-
117
Introduction
128
------------
139
PyTorch 1.8 includes an updated profiler API capable of
1410
recording the CPU side operations as well as the CUDA kernel launches on the GPU side.
1511
The profiler can visualize this information
1612
in TensorBoard Plugin and provide analysis of the performance bottlenecks.
1713
18-
In this recipe, we will use a simple Resnet model to demonstrate how to
19-
use profiler to analyze model performance.
14+
In this tutorial, we will use a simple Resnet model to demonstrate how to
15+
use TensorBoard plugin to analyze model performance.
2016
2117
Setup
2218
-----
@@ -98,7 +94,7 @@ def train(data):
9894
#
9995
# - ``schedule`` - callable that takes step (int) as a single parameter
10096
# and returns the profiler action to perform at each step;
101-
# In this example with wait=1, warmup=1, active=5,
97+
# In this example with ``wait=1, warmup=1, active=5``,
10298
# profiler will skip the first step/iteration,
10399
# start warming up on the second,
104100
# record the following five iterations,
@@ -108,7 +104,7 @@ def train(data):
108104
# During ``warmup`` steps, the profiler starts profiling as warmup but does not record any events.
109105
# This is for reducing the profiling overhead.
110106
# The overhead at the beginning of profiling is high and easy to bring skew to the profiling result.
111-
# During ``active`` steps, the profiler works and record events.
107+
# During ``active`` steps, the profiler works and records events.
112108
# - ``on_trace_ready`` - callable that is called at the end of each cycle;
113109
# In this example we use ``torch.profiler.tensorboard_trace_handler`` to generate result files for TensorBoard.
114110
# After profiling, result files will be saved into the ``./log/resnet18`` directory.
@@ -124,7 +120,7 @@ def train(data):
124120
if step >= 7:
125121
break
126122
train(batch_data)
127-
prof.step()
123+
prof.step() # Need call this at the end of each step to notify profiler of steps' boundary.
128124

129125

130126
######################################################################
@@ -228,15 +224,14 @@ def train(data):
228224
# .. image:: ../../_static/img/profiler_trace_view2.png
229225
# :scale: 25 %
230226
#
231-
# From the above view, we can find the event of ``enumerate(DataLoader)`` is shortened,
227+
# From the above view, we can see that the runtime of ``enumerate(DataLoader)`` is reduced,
232228
# and the GPU utilization is increased.
233229

234230
######################################################################
235231
# Learn More
236232
# ----------
237233
#
238-
# Take a look at the following recipes/tutorials to continue your learning:
234+
# Take a look at the following documents to continue your learning:
239235
#
240236
# - `Pytorch TensorBoard Profiler github <https://github.com/pytorch/kineto/tree/master/tb_plugin>`_
241-
# - `Pytorch Profiler <https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html>`_
242-
# - `Profiling Your Pytorch Module <https://pytorch.org/tutorials/beginner/profiler.html>`_ tutorial
237+
# - `torch.profiler API <https://pytorch.org/docs/master/profiler.html>`_

0 commit comments

Comments
 (0)