Skip to content

Instantly share code, notes, and snippets.

@kobybibas
Last active October 5, 2020 08:00
Show Gist options
  • Save kobybibas/259f26e3568c5b99f98fc1ba92a2ff40 to your computer and use it in GitHub Desktop.
Save kobybibas/259f26e3568c5b99f98fc1ba92a2ff40 to your computer and use it in GitHub Desktop.
Pytorch acceleration tips

Summry of the following guide https://nvlabs.github.io/eccv2020-mixed-precision-tutorial/files/szymon_migacz-pytorch-performance-tuning-guide.pdf

  1. In the dataset class
pin_memory=True
  1. Enable for device specific CNN acceleration
torch.backends.cudnn.benchmark = True
  1. Increase the batch size to max out GPU memory. SGD modification for large batch: LARS

  2. Disable bias for convlutaion if followed firectly by batch norm to reduce paramters. Instead

model.zero_grad()

use

for param in model.parameters():
    param.grad = None
  1. Add jit decorator to fuse cuda kernels
@torch.jit.script decorator to fuse cuda kernels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment