torch.cuda.manual_seed¶ torch.cuda.manual_seed(seed)[source][source]¶ 为当前 GPU 设置用于生成随机数的种子。 如果 CUDA 不可用,调用此函数是安全的;在这种情况下,它会被静默忽略。 参数 seed (int) – 期望的种子。 警告 如果您正在使用多 GPU 模型,此函数不足以保证确定性。要为所有 GPU 设置种子,请使用 manual_seed_all()。