Repository: pytorch
Issue: Segmentation fault on Pytorch 1.8.1 + cuda 11.1 on  GTX 1050 Ti 
Labels: high priority,needs reproduction,module: crash,module: cuda,triaged

## 🐛 Bug

Running a GAN structure on a personal project I came to bump into a segmentation error and I managed to reproduce the error on a quick MNIST GAN that I provide here (the GAN structure doesn't converge but that's not the point here) . The code runs with pytorch 1.8.1 + cuda 10.2 but does a segmentation error with pytorch 1.8.1 + cuda 11.1.
 I browsed before submitting so as not to make a duplicate but I couldn't find anything related to  segmentation error with this version (1.8.1+cu111). If 
## To Reproduce

Here is my code:


```python
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision.datasets import MNIST
from torchvision.transforms import ToTensor
from torch.utils.data import DataLoader
import torchvision
import torch.optim as optim
import numpy as np



def load_data(root="data"):
	transform = torchvision.transforms.Compose([
                               torchvision.transforms.ToTensor(),
                               torchvision.transforms.Normalize(
                                 (0.1307,), (0.3081,))
                             ])
	train_dataset = MNIST(root,train=True,transform=transform,download=True)
	test_dataset = MNIST(root,train=False,transform=transform,download=True)
	return train_dataset,test_dataset


class Generator(nn.Module):
	def __init__(self):
		super(Generator,self).__init__()
		m= [
		nn.ConvTranspose2d(10, 30, 3, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros'),
		nn.ReLU(),
		nn.ConvTranspose2d(30, 60, 5, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=2, padding_mode='zeros'),
		nn.ReLU(),
		nn.ConvTranspose2d(60, 120, 5, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros'),
		nn.ReLU(),
		nn.ConvTranspose2d(120, 160, 7, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros'),
		nn.ReLU(),
		nn.ConvTranspose2d(160, 1, 7, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros'),
		nn.Tanh()
		]
		self.seq = nn.Sequential(*m)
	def forward(self,x):
		return self.seq(x)

class Discriminator(nn.Module):
	def __init__(self):
		super(Discriminator,self).__init__()
		m=[nn.Conv2d(1,30,5),
			nn.MaxPool2d(2),
			nn.ReLU(),
			nn.Conv2d(30,60,5),
			nn.MaxPool2d(2),
			nn.ReLU(),
			nn.Conv2d(60,120,4),
			nn.ReLU()

		]
		self.seq = nn.Sequential(*m)
		self.lin=nn.Linear(120,1)
	def forward(self,x):
		return self.lin(self.seq(x).reshape(-1,120))





if __name__ =="__main__":
	device = torch.device('cuda')
	train_dataset,test_dataset = load_data()
	dataloader = DataLoader(train_dataset, batch_size=24, shuffle=True, sampler=None,
           batch_sampler=None, num_workers=4, collate_fn=None,
           pin_memory=True, drop_last=False, timeout=0,
           worker_init_fn=None, prefetch_factor=2,
           persistent_workers=False)
	gen = Generator()
	disc = Discriminator()
	gen.to(device)
	disc.to(device)
	optimizer_gen = optim.Adam(gen.parameters(),lr=0.00001)
	optimizer_disc = optim.Adam(disc.parameters(),lr=0.000001)

	log_gen=[]
	log_disc=[]

	for _ in range(100):
		for imgs,_ in iter(dataloader):
			imgs = imgs.to(device)
			#gen pass
			x = torch.randn(24,10,2,2,device=device)
			fake_img = gen(x)
			lamb_fake = torch.sigmoid(disc(fake_img))
			loss = -torch.sum(torch.log(lamb_fake))
			loss.backward()
			log_gen.append(loss.item())
			optimizer_gen.step()
			optimizer_gen.zero_grad()
			optimizer_disc.zero_grad()


			#disc pass
			x = torch.randn(24,10,2,2,device=device)
			fake_img = gen(x)
			lamb_fake = torch.sigmoid(disc(fake_img))
			lamb_real = torch.sigmoid(disc(imgs))
			loss2 = torch.sum(-torch.log(lamb_real)-torch.log(1-lamb_fake))/2
			loss2.backward()
			log_disc.append(loss2.item())
			optimizer_disc.step()
			optimizer_gen.zero_grad()
			optimizer_disc.zero_grad()

			# logs
			if len(log_gen)>100:
				print("Loss gen:",np.mean(log_gen))
				print("Loss disc:",np.mean(log_disc))
				log_gen = []
				log_disc = []
```

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## Environment

PyTorch version: 1.8.1+cu111
installed with 
Is debug build: False
CUDA used to build PyTorch: 11.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.2 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: version 3.16.3

Python version: 3.8 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: GeForce GTX 1050 Ti with Max-Q Design
Nvidia driver version: 460.32.03
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.1.1
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.5
[pip3] torch==1.8.1+cu111
[pip3] torchaudio==0.8.1
[pip3] torchvision==0.9.1+cu111
[conda] Could not collect


## Additional context
Environnement where is works:

PyTorch version: 1.8.1+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.2 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: version 3.16.3

Python version: 3.8 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: GeForce GTX 1050 Ti with Max-Q Design
Nvidia driver version: 460.32.03
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.1.1
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.5
[pip3] torch==1.8.1
[pip3] torchaudio==0.8.1
[pip3] torchvision==0.9.1
[conda] Could not collect



cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser @anjali411 @ngimel