title: RuntimeError: CUDA error: no kernel image is available for execution on the device after model.cuda()
body: <p>I am working on this model:</p>
  <pre><code>class Model(torch.nn.Module):
      def __init__(self, sizes, config):
          super(Model, self).__init__()
  
          self.lstm = []
          for i in range(len(sizes) - 2):
              self.lstm.append(LSTM(sizes[i], sizes[i+1], num_layers=8))
          self.lstm.append(torch.nn.Linear(sizes[-2], sizes[-1]).cuda())
          self.lstm = torch.nn.ModuleList(self.lstm)
  
          self.config_mel = config.mel_features
  
      def forward(self, x):
          # convert to log-domain
          x = x.clip(min=1e-6).log10()
  
          for layer in self.lstm[:-1]:
              x, _ = layer(x)
              x = torch.relu(x)
  
          #x = torch_unpack_seq(x)[0]
  
          x = self.lstm[-1](x)
          mask = torch.sigmoid(x)
  
          return mask
  </code></pre>
  <p>and then:</p>
  <pre><code>model = Model(model_width, config)
  model.cuda()
  </code></pre>
  <p>But I am getting this error:</p>
  <pre><code>File &quot;main.py&quot;, line 29, in &lt;module&gt;
      Model.train(args)
    File &quot;.../src/model.py&quot;, line 57, in train
      model.cuda()
    File &quot;.../.local/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 637, in cuda
      return self._apply(lambda t: t.cuda(device))
    File &quot;.../.local/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 530, in _apply
      module._apply(fn)
    File &quot;/.../.local/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 530, in _apply
      module._apply(fn)
    File &quot;.../.local/lib/python3.8/site-packages/torch/nn/modules/rnn.py&quot;, line 189, in _apply
      self.flatten_parameters()
    File &quot;.../.local/lib/python3.8/site-packages/torch/nn/modules/rnn.py&quot;, line 175, in flatten_parameters
      torch._cudnn_rnn_flatten_weight(
  RuntimeError: CUDA error: no kernel image is available for execution on the device
  CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
  For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
  </code></pre>
  <p>I have no idea why it is happening. I am trying to push model and the inputs in cuda, and I understand if the error was due to some models in CPU and some in GPU. But that is not the case here. I found some pip install solution here: <a href="https://stackoverflow.com/questions/65739700/pytorch-cuda-error-no-kernel-image-is-available-for-execution-on-the-device-on">Pytorch CUDA error: no kernel image is available for execution on the device on RTX 3090 with cuda 11.1</a></p>
  <p>but I cannot use it as I am trying to do the work in a remote repo where I don't have access to pip install.</p>
  <p>Is there a way I can solve this?</p>