torch.use_deterministic_algorithms
-
torch.use_deterministic_algorithms(d)[source] -
Sets whether PyTorch operations must use “deterministic” algorithms. That is, algorithms which, given the same input, and when run on the same software and hardware, always produce the same output. When True, operations will use deterministic algorithms when available, and if only nondeterministic algorithms are available they will throw a :class:RuntimeError when called.
Warning
This feature is in beta, and its design and implementation may change in the future.
The following normally-nondeterministic operations will act deterministically when
d=True:-
torch.nn.Conv1dwhen called on CUDA tensor -
torch.nn.Conv2dwhen called on CUDA tensor -
torch.nn.Conv3dwhen called on CUDA tensor -
torch.nn.ConvTranspose1dwhen called on CUDA tensor -
torch.nn.ConvTranspose2dwhen called on CUDA tensor -
torch.nn.ConvTranspose3dwhen called on CUDA tensor -
torch.bmm()when called on sparse-dense CUDA tensors -
torch.__getitem__()backward whenselfis a CPU tensor andindicesis a list of tensors -
torch.index_put()withaccumulate=Truewhen called on a CPU tensor
The following normally-nondeterministic operations will throw a
RuntimeErrorwhend=True:-
torch.nn.AvgPool3dwhen called on a CUDA tensor that requires grad -
torch.nn.AdaptiveAvgPool2dwhen called on a CUDA tensor that requires grad -
torch.nn.AdaptiveAvgPool3dwhen called on a CUDA tensor that requires grad -
torch.nn.MaxPool3dwhen called on a CUDA tensor that requires grad -
torch.nn.AdaptiveMaxPool2dwhen called on a CUDA tensor that requires grad -
torch.nn.FractionalMaxPool2dwhen called on a CUDA tensor that requires grad -
torch.nn.FractionalMaxPool3dwhen called on a CUDA tensor that requires grad -
torch.nn.functional.interpolate()when called on a CUDA tensor that requires grad and one of the following modes is used:linearbilinearbicubictrilinear
-
torch.nn.ReflectionPad1dwhen called on a CUDA tensor that requires grad -
torch.nn.ReflectionPad2dwhen called on a CUDA tensor that requires grad -
torch.nn.ReplicationPad1dwhen called on a CUDA tensor that requires grad -
torch.nn.ReplicationPad2dwhen called on a CUDA tensor that requires grad -
torch.nn.ReplicationPad3dwhen called on a CUDA tensor that requires grad -
torch.nn.NLLLosswhen called on a CUDA tensor that requires grad -
torch.nn.CTCLosswhen called on a CUDA tensor that requires grad -
torch.nn.EmbeddingBagwhen called on a CUDA tensor that requires grad -
torch.scatter_add_()when called on a CUDA tensor -
torch.index_add_()when called on a CUDA tensor torch.index_copy()-
torch.index_select()when called on a CUDA tensor that requires grad -
torch.repeat_interleave()when called on a CUDA tensor that requires grad -
torch.histc()when called on a CUDA tensor -
torch.bincount()when called on a CUDA tensor -
torch.kthvalue()with called on a CUDA tensor -
torch.median()with indices output when called on a CUDA tensor
A handful of CUDA operations are nondeterministic if the CUDA version is 10.2 or greater, unless the environment variable
CUBLAS_WORKSPACE_CONFIG=:4096:8orCUBLAS_WORKSPACE_CONFIG=:16:8is set. See the CUDA documentation for more details: https://docs.nvidia.com/cuda/cublas/index.html#cublasApi_reproducibility If one of these environment variable configurations is not set, aRuntimeErrorwill be raised from these operations when called with CUDA tensors:Note that deterministic operations tend to have worse performance than non-deterministic operations.
- Parameters
-
d (
bool) – If True, force operations to be deterministic. If False, allow non-deterministic operations.
-
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.use_deterministic_algorithms.html