tchaton edited a comment on issue #9648: BatchNorm Evaluation Mode Backward Fails with cudnn Enabled URL: https://github.com/apache/incubator-mxnet/issues/9648#issuecomment-522504996 Config: ubuntu 18.04 python 3.6.4 cuda_10.1.243_418.87.00_linux.run nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2017 NVIDIA Corporation Built on Fri_Nov__3_21:07:56_CDT_2017 Cuda compilation tools, release 9.1, V9.1.85 torch==1.1.0 Code to be run: ``` import torch import torch.nn as nn import torch.nn.functional as F import math import numpy as np def _upsample(x): h, w = x.shape[2:] return F.upsample_bilinear(x, size=(h * 2, w * 2)) def upsample_conv(x, conv): return conv(_upsample(x)) class genBlock(nn.Module): def __init__(self, in_channels, out_channels, activation=F.relu, hidden_channels=None, ksize=3, pad=1, upsample=False, n_classes=0): super(genBlock, self).__init__() self.activation = activation self.upsample = upsample self.learnable_sc = in_channels != out_channels or upsample hidden_channels = out_channels if hidden_channels is None else hidden_channels self.n_classes = n_classes self.c1 = nn.Conv2d(in_channels, hidden_channels, kernel_size=ksize, padding=pad) #nn.init.xavier_uniform_(self.c1.weight.data, math.sqrt(2)) self.c2 = nn.Conv2d(hidden_channels, out_channels, kernel_size=ksize, padding=pad) #nn.init.xavier_uniform_(self.c2.weight.data, math.sqrt(2)) self.b1 = nn.BatchNorm2d(in_channels) self.b2 = nn.BatchNorm2d(hidden_channels) if self.learnable_sc: self.c_sc = nn.Conv2d(in_channels, out_channels, kernel_size=ksize, padding=pad) def residual(self, x): h = x h = self.b1(h) h = self.activation(h) h = upsample_conv(h, self.c1) if self.upsample else self.c1(h) h = self.b2(h) h = self.activation(h) h = self.c2(h) return h def shortcut(self, x): if self.learnable_sc: x = upsample_conv(x, self.c_sc) if self.upsample else self.c_sc(x) return x else: return x def forward(self, input): return self.residual(input) + self.shortcut(input) if __name__== "__main__": noise = torch.randn(1,256, 4, 4).cuda() g = genBlock(256, 256, activation=F.relu, upsample=True).cuda() #g.apply(weights_init) out = g(noise) print(out.shape) ``` Traceback (most recent call last): File "test3.py", line 56, in <module> out = g(noise) File "/home/thomas/.pyenv/versions/spg3.6.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "test3.py", line 50, in forward return self.residual(input) + self.shortcut(input) File "test3.py", line 34, in residual h = self.b1(h) File "/home/thomas/.pyenv/versions/spg3.6.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "/home/thomas/.pyenv/versions/spg3.6.4/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 83, in forward exponential_average_factor, self.eps) File "/home/thomas/.pyenv/versions/spg3.6.4/lib/python3.6/site-packages/torch/nn/functional.py", line 1697, in batch_norm training, momentum, eps, torch.backends.cudnn.enabled RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
