Pytorch Torch Cuda Manual_Seed
# PyTorch torch.cuda.manual_seed Function
* * *
PyTorch torch Reference Manual
`torch.cuda.manual_seed` is a function in PyTorch for setting the random seed for CUDA operations. It sets the random seed for the current CUDA device to ensure reproducibility of CUDA operations.
### Function Definition
torch.cuda.manual_seed(seed)
* * *
## Usage Example
## Example
import torch
# Set CUDA random seed
if torch.cuda.is_available():
torch.cuda.manual_seed(42)
x = torch.randn(3,3).cuda()
print(f"Random tensor on CUDA: {x}")
# Same seed produces same result
torch.cuda.manual_seed(42)
y = torch.randn(3,3).cuda()
print(f"Random tensor with same seed: {y}")
else:
print("CUDA not available")
* * *
PyTorch torch Reference Manual
PyTorch Data Transformations
PyTorch torch.nn Reference Manual
[Byte Ark Coding Plan supports Doubao, GLM, DeepSeek, Kimi, MiniMax and other mainstream large models, officially supplied and stable. Configuration Guide Β₯9.9/month Immediate Activation](https://maas.xfyun.cn/modelSquare?ch=maas_lm_l2E)
YouTip