PyTorch torch.cuda.seed_all 関数


Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

torch.cuda.seed_allは、PyTorch においてすべての CUDA デバイスのランダムシードを設定するための関数です。すべての CUDA デバイスにランダムシードを設定します(機能は manual_seed_all と同じです)。

関数定義

torch.cuda.seed_all()

使用例

例

import torch

# すべての CUDA デバイスにランダムシードを設定
if torch.cuda.is_available():
    torch.cuda.seed_all()
    x = torch.randn(3, 3).cuda()
    print(f"Random tensor: {x}")
    print(f"CUDA device count: {torch.cuda.device_count()}")
else:
    print("CUDA not available")

Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

その他の拡張機能