The same CUDA version, different Pytorch versions, but different outputs

I run the code below by using Pytorch 0.4.1 and Pytorch 1.0.0 respectively with cuda 10.1.

model = nn.Linear(3,2).cuda()
x = torch.FloatTensor([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]).cuda()
with torch.no_grad():
    model.weight = torch.nn.Parameter(torch.cuda.FloatTensor([[1.0, 2.0, 1.0], [2.0, 3.0, 3.0]]))
    model.bias = torch.nn.Parameter(torch.cuda.FloatTensor([1.0, 2.0]))
    y = model(x)
    print(y)

The problem is that the outputs are different:

tensor([[17., 36.],
        [41., 84.]], device='cuda:0') # pytorch 0.4

tensor([[ 9., 19.],
        [21., 43.]], device='cuda:0') # pytorch 1.0

It’s quite amazing. Is there anyone can help me to solved it? Thanks.

I would recommend to stick to the latest release (1.7.1) and not use old releases such as 0.4 or 1.0, as these might have been known issues and should be already fixed.

Yeah, thank ptrblck.