Rnn.cuda() error (on Windows 10)

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

pinging @peterjc123 on windows issues

also, could you try a newer version? 0.2.1 is kinda old.

Is this how I would update it?

conda update -c peterjc123 pytorch cuda80

ref: https://github.com/peterjc123/pytorch-scripts

Yes, you can do that if you are using CUDA 8.0. There’s an indention bug in 0.2, you can change the file C:\Users\wbruc\Anaconda3\lib\site-packages\torch\backends\cudnn\__init__.py. It can be easily found in the init function.

Thank-you guys!

I still haven’t resolved this. Here’s what I’ve done:

UPDATING PYTORCH
I do have CUDA 8.0:

C:\Users\wbruc\Desktop\git_repos>nvcc -V

nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2016 NVIDIA Corporation
Built on Mon_Jan__9_17:32:33_CST_2017
Cuda compilation tools, release 8.0, V8.0.60

cuda80 wasn’t installed, so I installed it first, then upgraded:

conda install -c peterjc123 cuda80
conda update -c peterjc123 pytorch cuda80

Now torch.version is [[0.2.1+a4fc05a]]

Is it possible to upgrade to a newer version?
What is the newest version of pytorch? I have been unable to find this by googling - it seems there’s a 3.1 branch here: https://github.com/pytorch/pytorch

FINDING THE BUG
I looked at the init file and did not locate the indentation error (wasn’t exactly sure where to look)

I think I’ve narrowed down in the init file why the error is occurring:

I found and fixed the indentation bug (dedented the highlighted code here). Seems to be working. Thanks a lot!

image