Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Update tensorboard logging to plot test time details (#745)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #745

It is helpful to know the memory consumption and speed during test phases. Removed the epoch duration since it can be derived from the images / sec numbers

Reviewed By: lauragustafson

Differential Revision: D28308240

fbshipit-source-id: 08a7b2bed4a98528f94a88c90fcc5a2221a0e8a3
  • Loading branch information
mannatsingh authored and facebook-github-bot committed Jun 9, 2021
1 parent 504dff0 commit d09e519
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions classy_vision/hooks/tensorboard_plot_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@ def on_phase_end(self, task) -> None:
f"Parameters/{name}", parameter, global_step=phase_type_idx
)

if torch.cuda.is_available() and task.train:
if torch.cuda.is_available():
self.tb_writer.add_scalar(
"Memory/peak_allocated",
f"Memory/{phase_type}/peak_allocated",
torch.cuda.max_memory_allocated(),
global_step=phase_type_idx,
)

loss_avg = sum(task.losses) / batches

loss_key = "Losses/{phase_type}".format(phase_type=task.phase_type)
loss_key = f"Losses/{phase_type}"
self.tb_writer.add_scalar(loss_key, loss_avg, global_step=phase_type_idx)

# plot meters which return a dict
Expand Down
10 changes: 3 additions & 7 deletions classy_vision/tasks/classification_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ def on_phase_start(self):
self.phase_start_time_train = time.perf_counter()

def on_phase_end(self):
self.log_phase_end("train")
self.log_phase_end(self.phase_type)

if self.train:
self.optimizer.on_epoch(where=self.where)
Expand All @@ -1315,7 +1315,7 @@ def on_phase_end(self):
hook.on_phase_end(self)
self.perf_log = []

self.log_phase_end("total")
self.log_phase_end(f"{self.phase_type}_total")

if hasattr(self.datasets[self.phase_type], "on_phase_end"):
self.datasets[self.phase_type].on_phase_end()
Expand All @@ -1325,12 +1325,9 @@ def on_end(self):
hook.on_end(self)

def log_phase_end(self, tag):
if not self.train:
return

start_time = (
self.phase_start_time_train
if tag == "train"
if tag == self.phase_type
else self.phase_start_time_total
)
phase_duration = time.perf_counter() - start_time
Expand All @@ -1341,7 +1338,6 @@ def log_phase_end(self, tag):
{
"tag": tag,
"phase_idx": self.train_phase_idx,
"epoch_duration": phase_duration,
"im_per_sec": im_per_sec,
}
)
Expand Down

0 comments on commit d09e519

Please sign in to comment.