RuntimeError:渐变不是CUDA张量

时间:2017-03-30 23:44:21

标签: pytorch

我收到以下错误。

File "/net/if5/wua4nw/wasi/academic/research_with_prof_chang/projects/question_answering/duplicate_question_detection/source/train.py", line 62, in train
    loss.backward()
  File "/if5/wua4nw/anaconda3/lib/python3.5/site-packages/torch/autograd/variable.py", line 145, in backward
    self._execution_engine.run_backward((self,), (gradient,), retain_variables)
  File "/if5/wua4nw/anaconda3/lib/python3.5/site-packages/torch/autograd/function.py", line 208, in _do_backward
    result = super(NestedIOFunction, self)._do_backward(gradients, retain_variables)
  File "/if5/wua4nw/anaconda3/lib/python3.5/site-packages/torch/autograd/function.py", line 216, in backward
    result = self.backward_extended(*nested_gradients)
  File "/if5/wua4nw/anaconda3/lib/python3.5/site-packages/torch/nn/_functions/rnn.py", line 210, in backward_extended
    grad_hx)
  File "/if5/wua4nw/anaconda3/lib/python3.5/site-packages/torch/backends/cudnn/rnn.py", line 360, in backward_grad
    raise RuntimeError('Gradients aren\'t CUDA tensors')
RuntimeError: Gradients aren't CUDA tensors
在pytorch中运行loss.backward()

。正向传播工作正常但是当反向传播步骤执行时,我收到错误。谁能建议我如何解决这个问题?

P.S:我没有发布源代码,因为它太长了!

0 个答案:

没有答案