lmp.util.rand#

Randomness utilites.

lmp.util.rand.set_seed(seed: int) None[source]#

Do best effort to ensure reproducibility on the same machine.

Set random seed on random module, numpy.random, torch.manual_seed and torch.cuda.

Parameters

seed (int) – Controlled random seed which does best effort to make experiment reproducible. Must be bigger than 0.

See also

numpy.random.seed

Initialize the random number generator provided by Numpy.

random.seed

Initialize the random number generator provided by Python.

torch.backends.cudnn.benchmark

Use deterministic convolution algorithms.

torch.backends.cudnn.deterministic

Use deterministic convolution algorithms.

torch.cuda.manual_seed_all

Initialize the random number generator over all CUDA devices.

torch.manual_seed

Initialize the random number generator provided by PyTorch.

Notes

Reproducibility is not guaranteed accross different python/numpy/pytorch release, different os platforms or different hardwares (including CPUs and GPUs).