Search code examples
pythonrandompytorchrandom-seed

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


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

If yes, we can just use torch.manual_seed to set the seed. Otherwise we should call both functions.


Solution

  • Yes, torch.manual_seed() does include CUDA:

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