I get the following error from nn.RNN.cuda(), but not from other neural network modules I have used thus far.
TypeError: ‘>=’ not supported between instances of ‘NoneType’ and ‘int’
torch.cuda.is_available() is True
pytorch was installed via conda:
pytorch 0.2.1 py36he6bf560_0.2.1cu80 peterjc123
The Program Output and Stack Trace
torch.cuda.is_available() is [[True]]
Traceback (most recent call last):
File “C:/Users/wbruc/OneDrive/local_git_repos/2018-01-18-lesson_6_nietzsche/4_rnn/DEBUG_l6_1_nietszche_model.py”, line 26, in
m.cuda() # Exception is thrown here
File “C:\Users\wbruc\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 147, in cuda
return self._apply(lambda t: t.cuda(device_id))
File “C:\Users\wbruc\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 118, in _apply
module._apply(fn)
File “C:\Users\wbruc\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py”, line 116, in apply
self.flatten_parameters()
File “C:\Users\wbruc\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py”, line 95, in flatten_parameters
fn.rnn_desc = rnn.init_rnn_descriptor(fn, handle)
File “C:\Users\wbruc\Anaconda3\lib\site-packages\torch\backends\cudnn\rnn.py”, line 54, in init_rnn_descriptor
fn.datatype
File "C:\Users\wbruc\Anaconda3\lib\site-packages\torch\backends\cudnn_init.py", line 229, in init
if version() >= 6000:
TypeError: ‘>=’ not supported between instances of ‘NoneType’ and ‘int’Process finished with exit code 1
My code:
import torch
import torch.nn as nn
class Emb(nn.Module):
def __init__(self, vocab_size, n_fac, n_hidden):
super().__init__()
self.e = nn.Embedding(vocab_size, n_fac)
class HasRnn(nn.Module):
def __init__(self, vocab_size, n_fac, n_hidden):
super().__init__()
self.e = nn.Embedding(vocab_size, n_fac)
self.rnn = nn.RNN(n_fac, n_hidden)
if __name__ == '__main__':
print(f"\ntorch.cuda.is_available() is [[{torch.cuda.is_available()}]]")
m = Emb(vocab_size=8, n_fac=5, n_hidden=10)
m.cuda()
m = HasRnn(vocab_size=8, n_fac=5, n_hidden=10)
m.cuda() # Exception is thrown here