Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible make cuda deterministic?

I am trying to refactor an application and testing new against old version by comparing outputs. At the first pytorch conv layer using identical input I get identical output when using CPU. However using cuda on GPU the output tensors differ in the 5th decimal place on some cells. Is there any way to eliminate this difference? I am already setting:

random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True
like image 569
simon Avatar asked Jun 11 '26 04:06

simon


1 Answers

cpu and gpu can't produce the same result even if the seeds are set equal. Refer to this and this.

like image 132
AI葵 Avatar answered Jun 17 '26 18:06

AI葵



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!