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