Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Error when running your example and on AWD-LSTM-LM #21

Open
octavian-ganea opened this issue Sep 18, 2018 · 3 comments
Open

Error when running your example and on AWD-LSTM-LM #21

octavian-ganea opened this issue Sep 18, 2018 · 3 comments

Comments

@octavian-ganea
Copy link

I have python 3.5.2, pytorch 0.4.

>>> import torch
>>> from torchqrnn import QRNN
>>> 
>>> seq_len, batch_size, hidden_size = 7, 20, 256
>>> size = (seq_len, batch_size, hidden_size)
>>> X = torch.autograd.Variable(torch.rand(size), requires_grad=True).cuda()
>>> 
>>> qrnn = QRNN(hidden_size, hidden_size, num_layers=2, dropout=0.4)
>>> qrnn.cuda()
QRNN(
  (layers): ModuleList(
    (0): QRNNLayer(
      (linear): Linear(in_features=256, out_features=768, bias=True)
    )
    (1): QRNNLayer(
      (linear): Linear(in_features=256, out_features=768, bias=True)
    )
  )
)
>>> output, hidden = qrnn(X)
/home/oeganea/.local/lib/python3.5/site-packages/torch/nn/functional.py:995: UserWarning: nn.functional.tanh is deprecated. Use torch.tanh instead.
  warnings.warn("nn.functional.tanh is deprecated. Use torch.tanh instead.")
/home/oeganea/.local/lib/python3.5/site-packages/torch/nn/functional.py:1006: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
  warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/oeganea/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torchqrnn/qrnn.py", line 164, in forward
    input, hn = layer(input, None if hidden is None else hidden[i])
  File "/home/oeganea/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torchqrnn/qrnn.py", line 99, in forward
    C = ForgetMult()(F, Z, hidden, use_cuda=self.use_cuda)
  File "/home/oeganea/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torchqrnn/forget_mult.py", line 178, in forward
    if hidden_init is None: return GPUForgetMult()(f, x) if use_cuda else CPUForgetMult()(f, x)
  File "/usr/local/lib/python3.5/dist-packages/torchqrnn/forget_mult.py", line 120, in forward
    self.compile()
  File "/usr/local/lib/python3.5/dist-packages/torchqrnn/forget_mult.py", line 102, in compile
    program = Program(kernel.encode(), 'recurrent_forget_mult.cu'.encode())
  File "/usr/local/lib/python3.5/dist-packages/pynvrtc/compiler.py", line 52, in __init__
    include_names)
  File "/usr/local/lib/python3.5/dist-packages/pynvrtc/interface.py", line 200, in nvrtcCreateProgram
    c_char_p(encode_str(src)), c_char_p(encode_str(name)),
  File "/usr/local/lib/python3.5/dist-packages/pynvrtc/interface.py", line 54, in encode_str
    return s.encode("utf-8")
AttributeError: 'bytes' object has no attribute 'encode'

Also, QRNN fails on the AWD-LSTM-LM repo with a similar error:

  File "/home/oeganea/awd-lstm-lm/model.py", line 81, in forward
    raw_output, new_h = rnn(raw_output, hidden[l])
  File "/home/oeganea/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torchqrnn/qrnn.py", line 99, in forward
    C = ForgetMult()(F, Z, hidden, use_cuda=self.use_cuda)
  File "/home/oeganea/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torchqrnn/forget_mult.py", line 179, in forward
    return GPUForgetMult()(f, x, hidden_init) if use_cuda else CPUForgetMult()(f, x, hidden_init)
  File "/usr/local/lib/python3.5/dist-packages/torchqrnn/forget_mult.py", line 120, in forward
    self.compile()
  File "/usr/local/lib/python3.5/dist-packages/torchqrnn/forget_mult.py", line 102, in compile
    program = Program(kernel.encode(), 'recurrent_forget_mult.cu'.encode())
  File "/usr/local/lib/python3.5/dist-packages/pynvrtc/compiler.py", line 52, in __init__
    include_names)
  File "/usr/local/lib/python3.5/dist-packages/pynvrtc/interface.py", line 200, in nvrtcCreateProgram
    c_char_p(encode_str(src)), c_char_p(encode_str(name)),
  File "/usr/local/lib/python3.5/dist-packages/pynvrtc/interface.py", line 54, in encode_str
    return s.encode("utf-8")
AttributeError: 'bytes' object has no attribute 'encode'
Exception ignored in: <bound method Program.__del__ of <pynvrtc.compiler.Program object at 0x7f5aca839ef0>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/pynvrtc/compiler.py", line 56, in __del__
    self._interface.nvrtcDestroyProgram(self._program)
AttributeError: 'Program' object has no attribute '_program'

Any ideas ? Thanks!

@octavian-ganea
Copy link
Author

Any ideas ? Even the example in the readme or the ones in torchqrnn/qrnn.py don't work...

@msobroza
Copy link

msobroza commented Oct 16, 2018

Same problem. @octavian-ganea Did you find a solution for this problem ?

@htoyryla
Copy link

htoyryla commented Oct 25, 2018

This issue, in another project, look fairly similar.

https://github.com/taolei87/sru/issues/62

"The new version of pynvrtc assumes bytes objects instead of str objects as input to Program(). You can fix the error by removing encode ..."

Seems to me this pull request could be related to the same issue (removing encode when calling Program) #18

and then this is a duplicate of #17 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants