Skip to content

Commit 249411f

Browse files
committed
fix time benchmarking
1 parent 0cbf62c commit 249411f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

eval.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def evaluate(segmentation_module, loader, args):
5454
seg_label = as_numpy(batch_data['seg_label'][0])
5555
img_resized_list = batch_data['img_data']
5656

57-
tic = time.time()
57+
torch.cuda.synchronize()
58+
tic = time.perf_counter()
5859
with torch.no_grad():
5960
segSize = (seg_label.shape[0], seg_label.shape[1])
6061
scores = torch.zeros(1, args.num_class, segSize[0], segSize[1])
@@ -74,7 +75,8 @@ def evaluate(segmentation_module, loader, args):
7475
_, pred = torch.max(scores, dim=1)
7576
pred = as_numpy(pred.squeeze(0).cpu())
7677

77-
time_meter.update(time.time() - tic)
78+
torch.cuda.synchronize()
79+
time_meter.update(time.perf_counter() - tic)
7880

7981
# calculate accuracy
8082
acc, pix = accuracy(pred, seg_label)

0 commit comments

Comments
 (0)