How to ensure the repeatability of the results of the Pytorch model across devices?

I am a little bit confused about the randomness of the pytorch model.

I used the following code to fix the random seed so that the training results of the model can be repeated on the same device:

def seed_torch(seed=2020):
    random.seed(seed)
    os.environ["PYTHONHASHSEED"] = str(seed)
    np.random.seed(seed)
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)
    torch.backends.cudnn.deterministic = True
    torch.backends.cudnn.benchmark = False

But what is confusing is that when the code is run on another device with the same hardware configuration and software environment, it will produce different results.

I reinstalled the virtual environment to ensure that the versions of the libraries are consistent, but this problem still puzzles me.

Feel free to ask if more code is needed to explain the problem.

Refer to Reproducibility over Different Machines for the same discussion!