# RuntimeError: CUDNN\_STATUS\_MAPPING\_ERROR

**URL:** <https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370>\
**Category:** Uncategorized\
**Created:** [June 27, 2017, 1:56pm UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370 "2017-06-27T13:56:17Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeng](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/zeng/32/5451_2.png) [@zeng](https://discuss.pytorch.org/u/zeng)\
**Post date:** [June 27, 2017, 1:56pm UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/1 "2017-06-27T13:56:17Z")

</div>

When I use the code like

```auto
class Classify(nn.Module):
    def __init__ (self, opt):
        self.convs = [nn.Conv2d(1, opt.kernel_num, (k, opt.word_vec_size), padding=0) for k in opt.kernel_sizes]

    def forward(self, x):
        x = [F.relu(conv(x)).squeeze(3) for conv in self.convs]

```

I got the problem “ **RuntimeError: CUDNN\_STATUS\_MAPPING\_ERROR** ”, and I simple use the single **_Conv2d_** function is alright.

Does this kind of **_model list_ ([conv2d, conv2d, …])** have some problem with the cnn mapping?

---

<div class="post-metadata">

**Author:** ![xinwei\_he](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/xinwei_he/32/10987_2.png) [@xinwei\_he](https://discuss.pytorch.org/u/xinwei_he)\
**Post date:** [June 27, 2017, 2:16pm UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/2 "2017-06-27T14:16:56Z")

</div>

try below:

```auto
self.convs= nn.ModuleList([nn.Conv2d(1, opt.kernel_num, (k, opt.word_vec_size), padding=0) for k in opt.kernel_sizes]
)

```

---

<div class="post-metadata">

**Author:** ![McLawrence](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mclawrence/32/1496_2.png) [@McLawrence](https://discuss.pytorch.org/u/McLawrence)\
**Post date:** [August 10, 2017, 6:06am UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/3 "2017-08-10T06:06:42Z")

</div>

I get the same error message. My network has the following architecture:

```
class CNN(nn.Module):
def __init__ (self, num_classes=10):
    super(CNN, self). __init__ ()
    self.conv1 = nn.Conv2d(3, 32, 3, padding=1)
    self.conv2 = nn.Conv2d(32, 64, 3, padding=1)
    self.conv3 = nn.Conv2d(64, 128, 3, padding=1)
    self.pool = nn.MaxPool2d(2)
    self.classifier = nn.Sequential(
        nn.Linear(128*8*8 , 1024),
        nn.ReLU(True),
        nn.Dropout(),
        nn.Linear(1024, 1024),
        nn.ReLU(True),
        nn.Dropout(),
        nn.Linear(1024, num_classes)
    )

def forward(self, x):
    x = F.relu(self.conv1(x))
    x = self.pool(F.relu(self.conv2(x)))
    x = self.pool(F.relu(self.conv3(x)))
    x = x.view(x.size(0), -1)
    x = self.classifier(x)
    return x

```

The model works fine on CPU. I am using pytorch 0.1.12\_2

---

<div class="post-metadata">

**Author:** ![McLawrence](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mclawrence/32/1496_2.png) [@McLawrence](https://discuss.pytorch.org/u/McLawrence)\
**Post date:** [August 11, 2017, 4:24am UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/4 "2017-08-11T04:24:15Z")

</div>

I have found my mistake: I just did not know you have to do `net.cuda()`, too.

---

<div class="post-metadata">

**Author:** ![yuzhi\_guo](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/yuzhi_guo/32/14448_2.png) [@yuzhi\_guo](https://discuss.pytorch.org/u/yuzhi_guo)\
**Post date:** [July 7, 2018, 2:28am UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/5 "2018-07-07T02:28:31Z")

</div>

I think the problem is that your GPU is too old to supported by PyTorch. I got the same error before and I notice that there was an UserWarning in the middle part of my log. It was solved after I changed my GPU from K420 to GTX1050Ti.

---

<div class="post-metadata">

**Author:** ![Noosh\_Nabi](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/n/e0b2c6/32.png) [@Noosh\_Nabi](https://discuss.pytorch.org/u/Noosh_Nabi)\
**Post date:** [November 7, 2018, 11:35pm UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/6 "2018-11-07T23:35:37Z")

</div>

I faced the same problem and later on figured out the pytorch version I installed does not match CUDA version on my machine. I installed newer version of pytorch and it worked.  
CUDA version 9.2.88  
pytorch 0.4.1

---

<div class="post-metadata">

**Author:** ![mmisiur](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mmisiur/32/10162_2.png) [@mmisiur](https://discuss.pytorch.org/u/mmisiur)\
**Post date:** [July 3, 2019, 7:22am UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/7 "2019-07-03T07:22:03Z")

</div>

Just leaving this for the sake of future readers:  
I got this error when I’ve overclocked my GPU too much so the driver broke. Which also fits previous answers. So if you overclock and got this error, consider lowering the clock.

---

<div class="post-metadata">

**Author:** ![danpak94](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/d/e95f7d/32.png) [@danpak94](https://discuss.pytorch.org/u/danpak94)\
**Post date:** [September 24, 2019, 7:32pm UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/8 "2019-09-24T19:32:57Z")

</div>

I have the same error, but I have a different issue than everyone else. Here’s a simple code that reproduces my issue:

```auto
import torch
import torch.nn as nn
import numpy as np

class Net(nn.Module):
    def __init__ (self):
        super(Net, self). __init__ ()

        self.base_n_filter = 8

        self.conv1 = nn.Conv3d(1, self.base_n_filter, 3, stride=1, padding=1)
        self.conv2 = nn.Conv3d(self.base_n_filter, self.base_n_filter*2, 3, stride=1, padding=1)
        self.conv3 = nn.Conv3d(self.base_n_filter*2, 1, 3, stride=1, padding=1)

    def forward(self, img):
        output1 = self.conv1(img)
        output2 = self.conv2(output1)
        output3 = self.conv3(output2)

        return output3

if __name__ == ' __main__':
    img = torch.zeros([1,1,248,248,140]).cuda()
    label = torch.rand_like(img, device=img.device)

    model = Net().cuda()
    output = model(img)

    loss_fn = nn.MSELoss()

    loss = loss_fn(output, label)
    loss.backward()

```

The error only occurs when I have an input image of a specific size. For example, if I change the input to shape [1,1,250,250,150], the error no longer occurs. So it doesn’t seem like an overclocking issue. Additionally, this error also only occurs when self.base\_n\_filter is 8 or greater. I’m not using any lists to store my convolutions, and have set my model to cuda.

I am also using up-to-date GPU and cuda. The error occurs on both Tesla K80 and GTX1080Ti, with pytorch 1.2 cudatoolkit=10.0, CUDA/10.0.130, and cudnn/7.6.2.24-CUDA-10.0.130. Also, this error only occurs on Linux machines.

Any help would be truly appreciated!

---

<div class="post-metadata">

**Author:** ![BestJuly](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/bestjuly/32/12989_2.png) [@BestJuly](https://discuss.pytorch.org/u/BestJuly)\
**Post date:** [October 5, 2019, 1:31am UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/9 "2019-10-05T01:31:40Z")

</div>

I met the same thing and I felt strange because I run my code successfully once. In my situation, I reduced the batch size and solved this error.

---

<div class="post-metadata">

**Author:** ![danpak94](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/d/e95f7d/32.png) [@danpak94](https://discuss.pytorch.org/u/danpak94)\
**Post date:** [October 5, 2019, 6:28am UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/10 "2019-10-05T06:28:25Z")

</div>

In the code I posted, the batch size would be 1 so I don’t think that’s the problem. But it’s probably related to how only certain input shapes cause the error.

---

<div class="post-metadata">

**Author:** ![BestJuly](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/bestjuly/32/12989_2.png) [@BestJuly](https://discuss.pytorch.org/u/BestJuly)\
**Post date:** [December 9, 2019, 3:24pm UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/11 "2019-12-09T15:24:55Z")

</div>

I think you are right.  
When I run my codes, I found this error happened again and when I disabled cuDNN, the error disapeared. I think cuDNN may not so flexible for processing data in all shapes. That may be a bug in cuDNN. And as I posted, I found that sometimes using smaller batch\_size can avoid this error. However, in these cases, the occupation percentage of GPU memory is very low.

My environment: cuda v10.0.130, cudnn v7.6.5, V100.

---

<div class="post-metadata">

**Author:** ![Adam\_Levin](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/adam_levin/32/20480_2.png) [@Adam\_Levin](https://discuss.pytorch.org/u/Adam_Levin)\
**Post date:** [March 1, 2020, 3:34am UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/12 "2020-03-01T03:34:25Z")

</div>

I got this error because I was doing accumulated gradients (because I want my effective batch size to be larger than what can fit on my gpu at any given time) and this message showed when it tried to backprop the loss… seems like just a memory issue in some cases

---

<div class="post-metadata">

**Author:** ![thao](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/thao/32/26535_2.png) [@thao](https://discuss.pytorch.org/u/thao)\
**Post date:** [July 31, 2020, 9:01am UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/13 "2020-07-31T09:01:30Z")

</div>

Sometimes In my case, CUDA version is so high and torch version is old lead to this problem, you should upgrade to newer version.

---

<div class="post-metadata">

**Author:** ![Saurabh\_Kataria](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/saurabh_kataria/32/12442_2.png) [@Saurabh\_Kataria](https://discuss.pytorch.org/u/Saurabh_Kataria)\
**Post date:** [August 2, 2020, 10:53pm UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/14 "2020-08-02T22:53:09Z")

</div>

I also noticed some data shapes raise this cudnn error. I tried other data shape and it worked. For me, the error actually arose in batchnorm layer while forward pass.

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [August 3, 2020, 7:31am UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/15 "2020-08-03T07:31:18Z")

</div>

Could you post the input shapes and the batchnorm config as well as the cudnn version and used GPU, which raised this error?

---

<div class="post-metadata">

**Author:** ![Saurabh\_Kataria](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/saurabh_kataria/32/12442_2.png) [@Saurabh\_Kataria](https://discuss.pytorch.org/u/Saurabh_Kataria)\
**Post date:** [August 3, 2020, 5:14pm UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/16 "2020-08-03T17:14:29Z")

</div>

I found out that the issue was something else. When `CUDA_LAUNCH_BLOCKING=1` flag is not used with python script, it showed incorrect error CUDNN\_STATUS\_MAPPING\_ERROR (in my case, it said batchnorm failed). However, when the flag is used, I get “RuntimeError: CUDA error: device-side assert triggered” at line X. I manually checked that there was a index out of bounds problem at line X. Correcting it solved the problem.  
The real issue is that the code never tells that the problem is “index out of bounds”, but instead says CUDNN\_STATUS\_MAPPING\_ERROR or “RuntimeError: CUDA error: device-side assert triggered”, depending on if you are using `CUDA_LAUNCH_BLOCKING=1` or not.

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [August 4, 2020, 4:33am UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/17 "2020-08-04T04:33:15Z")

</div>

Yes, that’s unfortunately caused by the asynchronous CUDA kernel execution.  
Generally you should get a better error message by running the code on the CPU.  
If that’s not feasible (e.g. since it takes too long) or doesn’t create the error, you would have to rerun the code with `CUDA_LAUNCH_BLOCKING=1` to get the right line of code, which creates the error.

---

<div class="post-metadata">

**Author:** ![krishnachaitanya7](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/krishnachaitanya7/32/33870_2.png) [@krishnachaitanya7](https://discuss.pytorch.org/u/krishnachaitanya7)\
**Post date:** [May 4, 2022, 10:57pm UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/18 "2022-05-04T22:57:16Z")

</div>

In my case, I had a try-catch block inside the forward function. The logic was like this: try to index the input; if the indexing was not possible, just use the array as it is. While it worked for my case, whenever the code went into the exception, after some lines of code it was throwing  
CUDNN\_STATUS\_MAPPING\_ERROR. Just removed the try-catch block and there was no error. Just leaving it here in hope that it helps somebody.

---

<div class="post-metadata">

**Author:** ![hundun0322](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/hundun0322/32/53995_2.png) [@hundun0322](https://discuss.pytorch.org/u/hundun0322)\
**Post date:** [October 13, 2022, 2:20pm UTC](https://discuss.pytorch.org/t/runtimeerror-cudnn-status-mapping-error/4370/19 "2022-10-13T14:20:33Z")

</div>

I tried to use the cpu instead of gpu, found it could run with a slower speed. So I realised it must be related to the model. But as for me, the programme is based on machine vision.And when I use the ready img before, it runs smoothly. But failed when open the zed2 to capture the img then deal it. Then I upgrade the torch(1.6-1.7). Like the Metaphysics, bingo!
