Issue 1:
🐛 Bug

Integer overflow when doing 1x1 convolution on very large tensor

To Reproduce

This is the minimal code example that produces this bug.

import torch
import torch.nn as nn

conv = nn.Conv2d(128, 3, kernel_size=1).half().cuda()

test_tensor = torch.rand((1, 128, 4096, 4096), device='cuda', dtype=torch.float16)

with torch.no_grad():
out_tensor = conv(test_tensor)

Output:

---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-1-28bf39f6ead7> in <module>()
7
8 with torch.no_grad():
----> 9 out_tensor = conv(test_tensor)

2 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
720 result = self._slow_forward(*input, **kwargs)
721 else:
--> 722 result = self.forward(*input, **kwargs)
723 for hook in itertools.chain(
724 _global_forward_hooks.values(),

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py in forward(self, input)
417
418 def forward(self, input: Tensor) -> Tensor:
--> 419 return self._conv_forward(input, self.weight)
420
421 class Conv3d(_ConvNd):

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py in _conv_forward(self, input, weight)
414 _pair(0), self.dilation, self.groups)
415 return F.conv2d(input, weight, self.bias, self.stride,
--> 416 self.padding, self.dilation, self.groups)
417
418 def forward(self, input: Tensor) -> Tensor:

RuntimeError: N > 0 INTERNAL ASSERT FAILED at "/pytorch/aten/src/ATen/cuda/detail/KernelUtils.h":27, please report a bug to PyTorch. CUDA kernel launch blocks must be positive, but got N=-2147483648

Expected behavior

No RunTimeError, out_tensor is float16 tensor of shape 1x3x4096x4096.

Environment

PyTorch version: 1.6.0+cu101

Is debug build: False

CUDA used to build PyTorch: 10.1

OS: Ubuntu 18.04.3 LTS (x86_64)

GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

Clang version: 6.0.0-1ubuntu2 (tags/RELEASE_600/final)

CMake version: version 3.12.0

Python version: 3.6 (64-bit runtime)

Is CUDA available: True

CUDA runtime version: 10.1.243

GPU models and configuration: GPU 0: Tesla T4

Nvidia driver version: 418.67

cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5

Versions of relevant libraries:

[pip3] numpy==1.18.5

[pip3] torch==1.6.0+cu101

[pip3] torchsummary==1.5.1

[pip3] torchtext==0.3.1

[pip3] torchvision==0.7.0+cu101

[conda] Could not collect

Additional context

I ran this in Google Colab.

If I change number of groups in convolution to any N > 1, everything works fine.

cc @ezyang @gchanan @zou3519 @ngimel

Issue 2:
🐛 Bug

Get following error message when running torch.nn.Conv3d.forward():

N > 0 INTERNAL ASSERT FAILED at /tmp/pip-req-build-ltpwwdv7/aten/src/ATen/cuda/detail/KernelUtils.h:27, please report a bug to PyTorch. CUDA kernel launch blocks must be positive, but got N=-2147483648

To Reproduce

import torch

torch.backends.cudnn.enabled=False
x = torch.rand(1, 32, 512, 512, 256).to('cuda:0')
m = torch.nn.Conv3d(32, 1, kernel_size=1, padding=0,stride=1,bias=False).to('cuda:0')
x = m(x) # Assert!!

/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
530 result = self._slow_forward(*input, **kwargs)
531 else:
--> 532 result = self.forward(*input, **kwargs)
533 for hook in self._forward_hooks.values():
534 hook_result = hook(self, input, result)

/opt/conda/lib/python3.6/site-packages/torch/nn/modules/conv.py in forward(self, input)
478 self.dilation, self.groups)
479 return F.conv3d(input, self.weight, self.bias, self.stride,
--> 480 self.padding, self.dilation, self.groups)
481
482

RuntimeError: N > 0 INTERNAL ASSERT FAILED at /tmp/pip-req-build-ltpwwdv7/aten/src/ATen/cuda/detail/KernelUtils.h:27, please report a bug to PyTorch. CUDA kernel launch blocks must be positive, but got N=-2147483648

Environment

PyTorch version: 1.4.0a0+a5b4d78

Is debug build: False

CUDA used to build PyTorch: 10.2

OS: Ubuntu 18.04.3 LTS (x86_64)

GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

Clang version: Could not collect

CMake version: version 3.14.0

Python version: 3.6 (64-bit runtime)

Is CUDA available: True

CUDA runtime version: 10.2.89

GPU models and configuration:

GPU 0: Tesla V100-SXM2-32GB

Nvidia driver version: 440.33.01

cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5

cc @ezyang @gchanan @zou3519 @ngimel