torchfoo.seed_everything#

torchfoo.seed_everything(seed, deterministic=False)[source]#

Seed all random number generators for reproducibility.

Seeds random, torch, and torch.cuda (all devices). Optionally seeds numpy if it is installed.

Parameters:
  • seed (int) – the seed value to use

  • deterministic (bool) – if True, sets torch.use_deterministic_algorithms(True) and torch.backends.cudnn.benchmark = False. This will ensure reproducible results at the cost of reduced performance.