torch.manual_seed是否包括torch.cuda.manual_seed_all的操作?

Does torch.manual_seed include the operation of torch.cuda.manual_seed_all?

torch.manual_seed是否包括torch.cuda.manual_seed_all的操作?

如果是,我们可以直接使用torch.manual_seed设置种子。否则我们应该同时调用这两个函数。

参见Pytorch lightning's seed_everything

random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)

让我相信这些都是而且只是必需的种子。

是的,torch.manual_seed() 确实包括 CUDA:

You can use torch.manual_seed() to seed the RNG for all devices (both CPU and CUDA):