torchtnt.utils.env.seed¶
-
torchtnt.utils.env.
seed
(seed: int, deterministic: Optional[Union[str, int]] = None) None ¶ Function that sets seed for pseudo-random number generators across commonly used libraries.
This seeds PyTorch, NumPy, and the python.random module. For more details, see https://pytorch.org/docs/stable/notes/randomness.html.
Parameters: - seed – the integer value seed.
- deterministic – Controls determinism settings within PyTorch.
If None, don’t set any PyTorch global values.
If “default” or 0, don’t error or warn on nondeterministic operations and additionally enable PyTorch CuDNN benchmark.
If “warn” or 1, warn on nondeterministic operations and disable PyTorch CuDNN benchmark.
If “error” or 2, error on nondeterministic operations and disable PyTorch CuDNN benchmark.
For more details, see
torch.set_deterministic_debug_mode()
and https://pytorch.org/docs/stable/notes/randomness.html#avoiding-nondeterministic-algorithms.
Raises: ValueError – If the input seed value is outside the required range.