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