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