'How to get reproducible results with Keras/Tensorflow on different computers?

We are working on a deep learning project with a friend, and we would like to train the same model on our 2 different computers and get the same results. Is there a way we can do that?

Tensorflow version is 2.5.0

What we tried so far:
At the start of our code, in the first line of the main function, we set the Python Hash Seed to 0.

os.environ['PYTHONHASHSEED'] = str(0)

After that, in the training function we set the seeds appropriately.

random.seed(seed)
np.random.seed(seed)
tf.random.set_seed(seed)

On one computer, two runs with the same seed gives us the same result, however on the 2 different computers, the results are different. For example, with seed = 1, on my pc, the loss is around 0.09, but on my friend's it is lower than 0.06.
Why is that, and how can we solve it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source