Unable to reproduce results using PyTorch in Colab

I’m running a model written in PyTorch in Colab on P100 GPU and I have set all the seeds using the following code

torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
os.environ['PYTHONHASHSEED'] = str(seed)

Apart from the above, I have set seed value wherever it is required in the code.

I’m able to get reproducible results only when I run the code in the same session. When I close the session and then rerun the code in a new session, results are varying.
Is it not possible to get reproducible results using PyTorch in Colab? @smth @ptrblck

1 Like

One problem may be that when you start a new Collab session you might not get the same GPU. Sometimes you get a fast GPU and sometimes you get a slow GPU which you have to share with other Collab users. I don’t know if that makes any difference but it very well could.

Thanks for the information.

Every time I will run the code on P100 GPU only with the same RAM. To get reproducible results, isn’t enough to run the code on same type of GPU?

I don’t know. But as a first step ensure that you get identical results when you run the code on the cpu of your own computer.

What are you thoughts on this? @rasbt