Skip to content

Instantly share code, notes, and snippets.

@YunghuiHsu
Created May 4, 2022 07:09
Show Gist options
  • Select an option

  • Save YunghuiHsu/3dbfd9cf4ebcaa694737e873fe07dac4 to your computer and use it in GitHub Desktop.

Select an option

Save YunghuiHsu/3dbfd9cf4ebcaa694737e873fe07dac4 to your computer and use it in GitHub Desktop.
# caculate loss (forrward)
start_forward = time.time()
outputs = model(samples)
loss = criterion(outputs, targets)
end = time.time()
# caculate loss (forrward) & log time
torch.cuda.synchronize()
start_forward = time.time()
outputs = model(samples)
loss = criterion(outputs, targets)
torch.cuda.synchronize()
end = time.time()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment