<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>
<p dir="auto">While convert an RNN to onnx, it report this error.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/37336300/97544558-c14a5e80-1a04-11eb-81f3-cf6fbac242c6.png"><img src="https://user-images.githubusercontent.com/37336300/97544558-c14a5e80-1a04-11eb-81f3-cf6fbac242c6.png" alt="屏幕截图(4)" style="max-width: 100%;"></a></p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:<br>
1.While run this code on GPU this error will be reported.<br>
2.But if i run this code on CPU there is no error reported<br>
`<br>
import torch<br>
import torch.nn as nn</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="class StackedLSTM(nn.Module):
    def __init__(self, num_layers, input_size, rnn_size, dropout):
        super(StackedLSTM, self).__init__()
        self.dropout = nn.Dropout(dropout)
        self.num_layers = num_layers
        self.layers = nn.ModuleList()

        for _ in range(num_layers):
            self.layers.append(nn.LSTMCell(input_size, rnn_size))
            input_size = rnn_size

    def forward(self, input_feed, hidden):
        h_0, c_0 = hidden
        h_1, c_1 = [], []
        for i, layer in enumerate(self.layers):
            h_1_i, c_1_i = layer(input_feed, (h_0[i], c_0[i]))
            input_feed = h_1_i
            if i + 1 != self.num_layers:
                input_feed = self.dropout(input_feed)
            h_1 += [h_1_i]
            c_1 += [c_1_i]
        h_1 = torch.stack(h_1)
        c_1 = torch.stack(c_1)
        return input_feed, (h_1, c_1)

lstm = StackedLSTM(2, 580, 500, 0.3).cuda()
h_t = torch.randn(2, 10, 500).cuda()
h_c = torch.randn(2, 10, 500).cuda()
a = torch.randn(10, 580).cuda()
torch.onnx.export(lstm, (a, (h_t, h_c)), f='LSTM.onnx', opset_version=12, input_names=['input', 'h_t', 'h_c'], output_names= 
    ['output', 'hidden_t', 'hidden_c'])"><pre class="notranslate"><code class="notranslate">class StackedLSTM(nn.Module):
    def __init__(self, num_layers, input_size, rnn_size, dropout):
        super(StackedLSTM, self).__init__()
        self.dropout = nn.Dropout(dropout)
        self.num_layers = num_layers
        self.layers = nn.ModuleList()

        for _ in range(num_layers):
            self.layers.append(nn.LSTMCell(input_size, rnn_size))
            input_size = rnn_size

    def forward(self, input_feed, hidden):
        h_0, c_0 = hidden
        h_1, c_1 = [], []
        for i, layer in enumerate(self.layers):
            h_1_i, c_1_i = layer(input_feed, (h_0[i], c_0[i]))
            input_feed = h_1_i
            if i + 1 != self.num_layers:
                input_feed = self.dropout(input_feed)
            h_1 += [h_1_i]
            c_1 += [c_1_i]
        h_1 = torch.stack(h_1)
        c_1 = torch.stack(c_1)
        return input_feed, (h_1, c_1)

lstm = StackedLSTM(2, 580, 500, 0.3).cuda()
h_t = torch.randn(2, 10, 500).cuda()
h_c = torch.randn(2, 10, 500).cuda()
a = torch.randn(10, 580).cuda()
torch.onnx.export(lstm, (a, (h_t, h_c)), f='LSTM.onnx', opset_version=12, input_names=['input', 'h_t', 'h_c'], output_names= 
    ['output', 'hidden_t', 'hidden_c'])
</code></pre></div>
<p dir="auto">`</p>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">Convert this RNN to onnx while runing on GPU.</p>
<h2 dir="auto">Environment</h2>
<p dir="auto">PyTorch version: 1.7.0<br>
Is debug build: True<br>
CUDA used to build PyTorch: 10.2<br>
ROCM used to build PyTorch: N/A</p>
<p dir="auto">OS: Microsoft Windows 10 专业版<br>
GCC version: (GCC) 9.2.0<br>
Clang version: Could not collect<br>
CMake version: version 3.16.2</p>
<p dir="auto">Python version: 3.6 (64-bit runtime)<br>
Is CUDA available: True<br>
CUDA runtime version: 10.2.89<br>
GPU models and configuration: GPU 0: GeForce GTX 860M<br>
Nvidia driver version: 441.22<br>
cuDNN version: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\cudnn64_7.dll<br>
HIP runtime version: N/A<br>
MIOpen runtime version: N/A</p>
<p dir="auto">Versions of relevant libraries:<br>
[pip3] numpy==1.19.2<br>
[pip3] numpydoc==0.8.0<br>
[pip3] torch==1.7.0<br>
[pip3] torchaudio==0.7.0<br>
[pip3] torchtext==0.6.0<br>
[pip3] torchvision==0.8.1<br>
[conda] blas                      1.0                         mkl<br>
[conda] cpuonly                   1.0                           0    pytorch<br>
[conda] mkl                       2018.0.2                      1<br>
[conda] mkl-service               1.1.2            py36h57e144c_4<br>
[conda] mkl_fft                   1.0.1            py36h452e1ab_0<br>
[conda] mkl_random                1.0.1            py36h9258bd6_0<br>
[conda] numpy                     1.19.2                   pypi_0    pypi<br>
[conda] numpydoc                  0.8.0                    py36_0<br>
[conda] torch                     1.7.0                    pypi_0    pypi<br>
[conda] torchaudio                0.7.0                    pypi_0    pypi<br>
[conda] torchtext                 0.6.0                    pypi_0    pypi<br>
[conda] torchvision               0.8.1                    pypi_0    pypi</p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/houseroad/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/houseroad">@houseroad</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/spandantiwari/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/spandantiwari">@spandantiwari</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/lara-hdr/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/lara-hdr">@lara-hdr</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/BowenBao/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/BowenBao">@BowenBao</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/neginraoof/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/neginraoof">@neginraoof</a></p>
<p dir="auto">Hi guys:<br>
I have build a seq2seq model using nn.LSTMCELL in it. And I want to export a trained one to onnx form. However, when I do this, I have an error says:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="UserWarning: ONNX export failed on ATen operator _thnn_fused_lstm_cell because torch.onnx.symbolic_opset9._thnn_fused_lstm_cell does not exist
  .format(op_name, opset_version, op_name))"><pre class="notranslate"><code class="notranslate">UserWarning: ONNX export failed on ATen operator _thnn_fused_lstm_cell because torch.onnx.symbolic_opset9._thnn_fused_lstm_cell does not exist
  .format(op_name, opset_version, op_name))
</code></pre></div>
<p dir="auto">I think this maybe due to the opset nort supporting nn.LSTMCELL.<br>
Any one could help and share some advice?<br>
Thank you！</p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/albanD/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/albanD">@albanD</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mruberry/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mruberry">@mruberry</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/houseroad/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/houseroad">@houseroad</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/spandantiwari/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/spandantiwari">@spandantiwari</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/lara-hdr/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/lara-hdr">@lara-hdr</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/BowenBao/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/BowenBao">@BowenBao</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/neginraoof/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/neginraoof">@neginraoof</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/zou3519/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/zou3519">@zou3519</a></p>