8000 Failed when RNN run with cudnn with `requires_grad` set to `False` · Issue #776 · pytorch/pytorch · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Failed when RNN run with cudnn with requires_grad set to False #776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
meijieru opened this issue Feb 18, 2017 · 0 comm 8000 ents
Closed

Failed when RNN run with cudnn with requires_grad set to False #776

meijieru opened this issue Feb 18, 2017 · 0 comments
Assignees

Comments

@meijieru
Copy link
Contributor
meijieru commented Feb 18, 2017
import torch
import torch.nn as nn
from torch.autograd import Variable

lstm = nn.LSTM(2, 3, 1, bidirectional=True)
lstm.cuda()
for param in lstm.parameters():
    param.requires_grad = False  # NOTE: Failed when 'False' but succeed when 'True'

input = torch.ones(4, 5, 2)  # [T, b, i]
input = input.cuda()
input = Variable(input, requires_grad=True)
output, _ = lstm(input)
output.backward(torch.ones(output.size()).cuda())

When run on cpu or requires_grad set to True, it does succeed.
Otherwise, it fails with error message:

Traceback (most recent call last):
  File "test_lstm.py", line 17, in <module>
    output.backward(torch.ones(output.size()).cuda())
  File "/home/jrmei/.local/lib/python2.7/site-packages/torch/autograd/variable.py", line 158, in backward
    self._execution_engine.run_backward((self,), (gradient,), retain_variables)
RuntimeError: CudnnRNN returned an invalid number of gradient tensors (expected 11, but got 4)

It seems like the check done by the framework has a bug.

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

No branches or pull requests

3 participants
0