Skip to content

Commit 532b321

Browse files
committed
Fix CI spelling error
1 parent 639d4ca commit 532b321

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

intermediate_source/tensorboard_profiler_tutorial.py

+19-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Introduction
88
------------
99
PyTorch 1.8 includes an updated profiler API capable of
10-
recording the CPU side operations as well as the CUDA kernel launches on the GPU side (ROCm AMD GPUs are not supported).
10+
recording the CPU side operations as well as the CUDA kernel launches on the GPU side (``AMD ROCm™`` GPUs are not supported).
1111
The profiler can visualize this information
1212
in TensorBoard Plugin and provide analysis of the performance bottlenecks.
1313
@@ -57,18 +57,19 @@
5757
# Transform it to the desired format and use ``DataLoader`` to load each batch.
5858

5959
transform = T.Compose(
60-
[T.Resize(224),
61-
T.ToTensor(),
62-
T.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
63-
train_set = torchvision.datasets.CIFAR10(root='./data', train=True, download=True, transform=transform)
60+
[T.Resize(224), T.ToTensor(), T.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))]
61+
)
62+
train_set = torchvision.datasets.CIFAR10(
63+
root="./data", train=True, download=True, transform=transform
64+
)
6465
train_loader = torch.utils.data.DataLoader(train_set, batch_size=32, shuffle=True)
6566

6667
######################################################################
6768
# Next, create Resnet model, loss function, and optimizer objects.
6869
# To run on GPU, move model and loss to GPU device.
6970

7071
device = torch.device("cuda:0")
71-
model = torchvision.models.resnet18(weights='IMAGENET1K_V1').cuda(device)
72+
model = torchvision.models.resnet18(weights="IMAGENET1K_V1").cuda(device)
7273
criterion = torch.nn.CrossEntropyLoss().cuda(device)
7374
optimizer = torch.optim.SGD(model.parameters(), lr=0.001, momentum=0.9)
7475
model.train()
@@ -77,6 +78,7 @@
7778
######################################################################
7879
# Define the training step for each batch of input data.
7980

81+
8082
def train(data):
8183
inputs, labels = data[0].to(device=device), data[1].to(device=device)
8284
outputs = model(inputs)
@@ -120,11 +122,11 @@ def train(data):
120122
# clicking a stack frame will navigate to the specific code line.
121123

122124
with torch.profiler.profile(
123-
schedule=torch.profiler.schedule(wait=1, warmup=1, active=3, repeat=1),
124-
on_trace_ready=torch.profiler.tensorboard_trace_handler('./log/resnet18'),
125-
record_shapes=True,
126-
profile_memory=True,
127-
with_stack=True
125+
schedule=torch.profiler.schedule(wait=1, warmup=1, active=3, repeat=1),
126+
on_trace_ready=torch.profiler.tensorboard_trace_handler("./log/resnet18"),
127+
record_shapes=True,
128+
profile_memory=True,
129+
with_stack=True,
128130
) as prof:
129131
for step, batch_data in enumerate(train_loader):
130132
prof.step() # Need to call this at each step to notify profiler of steps' boundary.
@@ -135,10 +137,11 @@ def train(data):
135137
######################################################################
136138
# Alternatively, the following non-context manager start/stop is supported as well.
137139
prof = torch.profiler.profile(
138-
schedule=torch.profiler.schedule(wait=1, warmup=1, active=3, repeat=1),
139-
on_trace_ready=torch.profiler.tensorboard_trace_handler('./log/resnet18'),
140-
record_shapes=True,
141-
with_stack=True)
140+
schedule=torch.profiler.schedule(wait=1, warmup=1, active=3, repeat=1),
141+
on_trace_ready=torch.profiler.tensorboard_trace_handler("./log/resnet18"),
142+
record_shapes=True,
143+
with_stack=True,
144+
)
142145
prof.start()
143146
for step, batch_data in enumerate(train_loader):
144147
prof.step()
@@ -356,7 +359,7 @@ def train(data):
356359
# ``aten::empty`` to allocate memory. For example, ``aten::ones`` is implemented as ``aten::empty`` followed by an
357360
# ``aten::fill_``. Solely display the operator name as ``aten::empty`` is of little help. It will be shown as
358361
# ``aten::ones (aten::empty)`` in this special case. The "Allocation Time", "Release Time" and "Duration"
359-
# columns' data might be missing if the event occurs outside of the time range.
362+
# columns' data might be missing if the event occurs outside of the time range.
360363
#
361364
# In the memory statistics table, the "Size Increase" column sums up all allocation size and minus all the memory
362365
# release size, that is, the net increase of memory usage after this operator. The "Self Size Increase" column is

0 commit comments

Comments
 (0)