Repository: pytorch
Issue: Model produces same outputs for different inputs when using GPU
Labels: needs reproduction,module: cuda,triaged

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->
A very simple model produces exactly identical outputs for random inputs.
This behavior occurs only when using the GPU. On CPU it works as expected
## To Reproduce

Code to reproduce the behavior:
```
import torch
import torch.nn.functional as F
import torch.nn as nn

class LeNet5(nn.Module):
    def __init__(self, embedding_dim=500):
        super(LeNet5, self).__init__()
        self.embedding_dim = embedding_dim
        self.conv1 = nn.Conv2d(in_channels=1, out_channels=20, kernel_size=5)
        self.conv2 = nn.Conv2d(in_channels=20, out_channels=50, kernel_size=5)
        self.fc = nn.Linear(4*4*50, embedding_dim)

    def forward(self, x):
        hh = self.conv1(x)
        hh = F.relu(hh)
        hh = F.max_pool2d(hh, 2)

        hh = self.conv2(hh)
        hh = F.relu(hh)
        hh = F.max_pool2d(hh, 2)

        hh = hh.view(hh.size(0), -1)
        hh = F.relu(self.fc(hh))
        return hh

cnn = LeNet5(500)
x = torch.rand(4, 1, 28, 28)
h = cnn(x)
print(torch.equal(h[1], h[2])) # this yields False, as expected

cnn = cnn.cuda()
x = x.cuda()
h = cnn(x)
print(torch.equal(h[1], h[2])) # this yields True, not as expected

## After the above print, the code throws a segmentation fault (at least in my setup)
```

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

## Expected behavior
The computed features should be different for different inputs

## Environment

PyTorch version: 1.7.1
Is debug build: False
CUDA used to build PyTorch: 11.0
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.5 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: Could not collect
CMake version: Could not collect

Python version: 3.7 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: 11.0.194
GPU models and configuration: GPU 0: GeForce GTX 1070 Ti
Nvidia driver version: 450.66
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.2
[pip3] pytorch-lightning==1.1.4
[pip3] torch==1.7.1
[pip3] torchaudio==0.7.0a0+a853dff
[pip3] torchvision==0.8.2
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.0.221             h6bb024c_0  
[conda] mkl                       2020.2                      256  
[conda] mkl-service               2.3.0            py37he8ac12f_0  
[conda] mkl_fft                   1.2.0            py37h23d657b_0  
[conda] mkl_random                1.1.1            py37h0573a6f_0  
[conda] numpy                     1.19.2           py37h54aff64_0  
[conda] numpy-base                1.19.2           py37hfa32c7d_0  
[conda] pytorch                   1.7.1           py3.7_cuda11.0.221_cudnn8.0.5_0    pytorch
[conda] pytorch-lightning         1.1.4              pyhd8ed1ab_0    conda-forge
[conda] torchaudio                0.7.2                      py37    pytorch
[conda] torchvision               0.8.2                py37_cu110    pytorch


## Additional context

<!-- Add any other context about the problem here. -->


cc @ngimel