# \[resolved\] BatchNorm1d -\> CUDNN\_STATUS\_NOT\_SUPPORTED

**URL:** <https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049>\
**Category:** Uncategorized\
**Created:** [May 16, 2017, 2:29am UTC](https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049 "2017-05-16T02:29:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pchalasani](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/pchalasani/32/223_2.png) [@pchalasani](https://discuss.pytorch.org/u/pchalasani)\
**Post date:** [May 16, 2017, 2:29am UTC](https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049/1 "2017-05-16T02:29:51Z")

</div>

Here’s a minimal example (never mind that it looks strange):

```auto
import torch.nn as nn
x = Variable( t.rand(10000000,1)).cuda()
bn = nn.BatchNorm1d(1)
bn.cuda()
xbn = bn(x)

```

I get the stack-trace below. I recall from some other thread that **I would need to build PyTorch from branch R4** to get rid of this? Is that still the case? I’m using PyTorch built from master a month ago on the AWS Deep Learning Ubuntu AMI instance, and I get this error on that instance.

Thanks !

```auto
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-25-6584c2ec408e> in <module>()
      6 bn = nn.BatchNorm1d(1)
      7 bn.cuda()
----> 8 x1cbn = bn(x)
      9 x1cbn.size()

/home/ubuntu/src/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.pyc in __call__ (self, *input, **kwargs)
    200 
    201 def __call__ (self, *input, **kwargs):
--> 202 result = self.forward(*input, **kwargs)
    203 for hook in self._forward_hooks.values():
    204 hook_result = hook(self, input, result)

/home/ubuntu/src/anaconda2/lib/python2.7/site-packages/torch/nn/modules/batchnorm.pyc in forward(self, input)
     41 return F.batch_norm(
     42 input, self.running_mean, self.running_var, self.weight, self.bias,
---> 43 self.training, self.momentum, self.eps)
     44 
     45 def __repr__ (self):

/home/ubuntu/src/anaconda2/lib/python2.7/site-packages/torch/nn/functional.pyc in batch_norm(input, running_mean, running_var, weight, bias, training, momentum, eps)
    387 training=False, momentum=0.1, eps=1e-5):
    388 f = torch._C._functions.BatchNorm(running_mean, running_var, training, momentum, eps)
--> 389 return f(input, weight, bias)
    390 
    391 

RuntimeError: CUDNN_STATUS_NOT_SUPPORTED. This error may appear if you passed in a non-contiguous input.

```

---

<div class="post-metadata">

**Author:** ![pchalasani](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/pchalasani/32/223_2.png) [@pchalasani](https://discuss.pytorch.org/u/pchalasani)\
**Post date:** [May 17, 2017, 1:13am UTC](https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049/2 "2017-05-17T01:13:51Z")

</div>

This is with Cuda 8.0, cudnn 6, Ubuntu 14.04 (the Amazon Deep Learning AMI), with PyTorch installed from source a couple months ago.

And incidentally it works fine if I use a smaller tensor size, like say 100000 instead of 10000000

---

<div class="post-metadata">

**Author:** ![albanD](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alband/32/215_2.png) [@albanD](https://discuss.pytorch.org/u/albanD)\
**Post date:** [May 17, 2017, 8:38am UTC](https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049/3 "2017-05-17T08:38:31Z")

</div>

Hi,  
You may want to wait for a response from an nvidia guy, but from what I remember, some very weird input shapes are not supported by cudnn (for various reasons like for example your gpu not having enough memory for the required workspace). Given that in your case feeding a smaller tensor works, it may be the reason.

You can try disabling cudnn with `torch.backends.cudnn.enabled=False` and see if it works.

---

<div class="post-metadata">

**Author:** ![pchalasani](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/pchalasani/32/223_2.png) [@pchalasani](https://discuss.pytorch.org/u/pchalasani)\
**Post date:** [May 17, 2017, 2:09pm UTC](https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049/4 "2017-05-17T14:09:25Z")

</div>

Thanks @albanD I did this and it did not fix it:

```auto
import torch
import torch.nn as nn

torch.backends.cudnn.enabled=False
x = Variable( t.rand(1000000,1).contiguous()).cuda()

print torch.backends.cudnn.version()

bn = nn.BatchNorm1d(1)
bn.cuda()

xbn = bn(x)
xbn.size()

```

---

<div class="post-metadata">

**Author:** ![albanD](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alband/32/215_2.png) [@albanD](https://discuss.pytorch.org/u/albanD)\
**Post date:** [May 17, 2017, 4:12pm UTC](https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049/5 "2017-05-17T16:12:19Z")

</div>

Hi, I cannot reproduce your problem. Running the code sample that you gave does not raise any cudnn error anymore for me.

---

<div class="post-metadata">

**Author:** ![pchalasani](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/pchalasani/32/223_2.png) [@pchalasani](https://discuss.pytorch.org/u/pchalasani)\
**Post date:** [May 17, 2017, 4:13pm UTC](https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049/6 "2017-05-17T16:13:30Z")

</div>

did you try with a larger size like 10 Million ?

---

<div class="post-metadata">

**Author:** ![albanD](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alband/32/215_2.png) [@albanD](https://discuss.pytorch.org/u/albanD)\
**Post date:** [May 17, 2017, 4:16pm UTC](https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049/7 "2017-05-17T16:16:41Z")

</div>

Yes, this exact code works for me (after freezing my computer for few second due to memory usage) and outputs:  
6021  
(100000000L, 1L)

```auto
import torch
from torch.autograd import Variable
import torch.nn as nn

torch.backends.cudnn.enabled=False
x = Variable( torch.rand(100000000,1).contiguous()).cuda()

print torch.backends.cudnn.version()

bn = nn.BatchNorm1d(1)
bn.cuda()

xbn = bn(x)
print(xbn.size())

```

---

<div class="post-metadata">

**Author:** ![pchalasani](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/pchalasani/32/223_2.png) [@pchalasani](https://discuss.pytorch.org/u/pchalasani)\
**Post date:** [May 17, 2017, 4:19pm UTC](https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049/8 "2017-05-17T16:19:01Z")

</div>

Ah my version shows 5110, so looks like I’m still on cudnn 5, although I **thought** I installed 6.0

---

<div class="post-metadata">

**Author:** ![pchalasani](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/pchalasani/32/223_2.png) [@pchalasani](https://discuss.pytorch.org/u/pchalasani)\
**Post date:** [May 17, 2017, 4:24pm UTC](https://discuss.pytorch.org/t/resolved-batchnorm1d-cudnn-status-not-supported/3049/9 "2017-05-17T16:24:32Z")

</div>

Turned out I had forgotten to re-build PyTorch from source after installing the cudnn 6.0 files. Now it works fine.
