KeyError: 'GRU'

username: jngk2
cooked: <p>Using <code>torch (1.1.0)</code>, <code>flair (0.4.2)</code> [1], I get the following error when I try to train a model.</p>
<pre><code class="lang-auto">  File "/home/foobar/github/cbd/venv/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 204, in forward
    _impl = _rnn_impls[self.mode]
KeyError: 'GRU'
</code></pre>
<p>Python interpeter</p>
<pre><code class="lang-auto">&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.version.cuda
'10.0.130'
&gt;&gt;&gt; torch.cuda.is_available()
True
</code></pre>
<p>My understanding is a bit shaky. Should the version of <code>nvcc compilation tools</code> align with <code>torch</code>'s cuda version? It doesn’t, but as you can see above, cuda is still available.</p>
<p>If there’s anything I’ve missed that might help diagnosing, please say.</p>
<p>Shell</p>
<pre><code class="lang-auto">$ nvcc --version
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
</code></pre>
<p>[1] Flair NLP – <a href="https://github.com/zalandoresearch/flair" rel="nofollow noopener">https://github.com/zalandoresearch/flair</a></p>
<p>Full error</p>
<pre><code class="lang-auto">2019-08-12 17:49:33,828 Reading data from /home/foobar/tmp/splits
2019-08-12 17:49:33,828 Train: /home/foobar/tmp/splits/train.txt
2019-08-12 17:49:33,828 Dev: /home/foobar/tmp/splits/dev.txt
2019-08-12 17:49:33,828 Test: /home/foobar/tmp/splits/test.txt
2019-08-12 17:59:10,064 {'noncb', 'cb'}
2019-08-12 18:08:17,296 ----------------------------------------------------------------------------------------------------
2019-08-12 18:08:17,296 Evaluation method: MICRO_F1_SCORE
Traceback (most recent call last):
  File "/home/foobar/github/cbd/venv/bin/cbd-train", line 11, in &lt;module&gt;
    load_entry_point('cbd', 'console_scripts', 'cbd-train')()
  File "/home/foobar/github/cbd/cb/train.py", line 50, in train
    max_epochs=150)
  File "/home/foobar/github/cbd/venv/lib/python3.6/site-packages/flair/trainers/trainer.py", line 93, in train
    embeddings_in_memory,
  File "/home/foobar/github/cbd/venv/lib/python3.6/site-packages/flair/models/text_classification_model.py", line 177, in evaluate
    labels, loss = self.forward_labels_and_loss(batch)
  File "/home/foobar/github/cbd/venv/lib/python3.6/site-packages/flair/models/text_classification_model.py", line 108, in forward_labels_and_loss
    scores = self.forward(sentences)
  File "/home/foobar/github/cbd/venv/lib/python3.6/site-packages/flair/models/text_classification_model.py", line 70, in forward
    self.document_embeddings.embed(sentences)
  File "/home/foobar/github/cbd/venv/lib/python3.6/site-packages/flair/embeddings.py", line 2081, in embed
    rnn_out, hidden = self.rnn(packed)
  File "/home/foobar/github/cbd/venv/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/foobar/github/cbd/venv/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 204, in forward
    _impl = _rnn_impls[self.mode]
KeyError: 'GRU'
</code></pre>

username: kl_divergence
cooked: <p>You cuda version should match with what pytorch expects. Perhaps, you can try uninstalling pytorch and installing it again with correct cuda version. It seems that you have different cuda installations.</p>

username: Kinal_Mehta
cooked: <p>Getting same error with flair 0.4.3 and torch 1.2.0</p>
<p>System Cuda version</p>
<pre><code class="lang-auto">(py36) ➜  question_classifier_new_test nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
</code></pre>
<p>Pytorch Cuda version</p>
<pre><code class="lang-auto">Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import torch 
&gt;&gt;&gt; torch.version.cuda
'10.0.130'
</code></pre>
<p>I was working the other time, and now its not. anything missing.</p>
<p>version 1.1.0 works fine but in 1.2.0, GRU and LSTM are removed to add torchscript support, refer link <a href="https://pytorch.org/docs/stable/_modules/torch/nn/modules/rnn.html" rel="nofollow noopener">https://pytorch.org/docs/stable/_modules/torch/nn/modules/rnn.html</a></p>