Skip to content

Commit

Permalink
Move timer initialization above to make it process safe (#494)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #494

Reviewed By: crassirostris

Differential Revision: D48170590

fbshipit-source-id: 65f2d2f74bbb9da0a0e4409c12772d42de48a4cc
  • Loading branch information
krishnakumar-kapil authored and facebook-github-bot committed Aug 9, 2023
1 parent 7dbedcb commit 84219f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchtnt/utils/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def time(
Args:
action_name: the name under which to store the timing of what is enclosed in the context manager.
"""
start_time: float = perf_counter()
try:
if self.cuda_sync:
torch.cuda.synchronize()
start_time: float = perf_counter()
yield
finally:
if self.cuda_sync:
Expand Down

0 comments on commit 84219f0

Please sign in to comment.