Home > Mobile >  manual_seed for mps devices in pytorch
manual_seed for mps devices in pytorch

Time:11-30

How do I set up a manual seed for mps devices using pytorch? With cuda devices the code should work like this:

if torch.cuda.is_available():
  torch.cuda.manual_seed(0)

I'm using an apple m1 chip. The following statement returns True:

torch.backends.mps.is_available()

But following statement is not possible:

torch.backends.mps.manual_seed(0)

CodePudding user response:

According to the docs:

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

import torch
torch.manual_seed(0)
  • Related