PyTorch torch.cuda.seed_all function
PyTorch torch reference manual
torch.cuda.seed_all is a PyTorch function for setting random seeds for all CUDA devices. It sets the random seed for every CUDA device (same as manual_seed_all).
Function definition
torch.cuda.seed_all()
Usage examples
Example
import
torch
Set random seeds for all CUDA devices
if
torch.
cuda
.
is_available
(
)
:
torch.
cuda
.
seed_all
(
)
x
=
torch.
randn
(
3
,
3
)
.
cuda
(
)
(
f
"Random tensor: {x}"
)
(
f
"CUDA device count: {torch.cuda.device_count()}"
)
else
:
(
"CUDA not available"
)