PyTorch torch.cuda.seed Function


Pytorch torch 参考手册Pytorch torch Reference Manual

torch.cuda.seedIs a function in PyTorch used to set the CUDA random seed. Sets the random seed for the current CUDA device (functionally the same as manual_seed).

Function Definition

torch.cuda.seed()

Usage Example

Example

import torch

# Set CUDA random seed
if torch.cuda.is_available():
    torch.cuda.seed()
    x = torch.randn(3, 3).cuda()
    print(f"Random tensor on CUDA: {x}")
else:
    print("CUDA not available")

Pytorch torch 参考手册Pytorch torch Reference Manual

Other Extensions