You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It throws another error (only on the second call!):
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-29-62893995fdbc> in <module>
----> 1 scripted_laplacian(torch.randn(10, 3))
~/miniconda3/lib/python3.7/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
887 result = self._slow_forward(*input, **kwargs)
888 else:
--> 889 result = self.forward(*input, **kwargs)
890 for hook in itertools.chain(
891 _global_forward_hooks.values(),
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
File "<ipython-input-25-7a172cd7c8d6>", line 19, in forward
y = self.model(x)
# First order gradients
dy_dx = torch.autograd.grad(
~~~~~~~~~~~~~~~~~~~ <--- HERE
[y.sum()], [x], create_graph=True)[0]
if dy_dx is not None:
RuntimeError: One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior.
CC @Krovatkin, you were looking into this error: RuntimeError: kind_.is_prim() INTERNAL ASSERT FAILED at "/pytorch/torch/csrc/jit/ir/ir.cpp":1098, please report a bug to PyTorch. Only prim ops are allowed to not have a registered operator but aten::cat doesn't have one either. We don't know if this op has side effects..
RuntimeError: One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior.
馃悰 Bug
Computing second oder grads in TorchScript works a single time but when used again, fails.
To Reproduce
One can initialize the model
And the first call works just fine
However, if I now call the model a second time it fails
Expected behavior
The second call should return correctly like the first one.
Environment
conda
,pip
, source): pipAdditional context
cc @gmagogsfm
The text was updated successfully, but these errors were encountered: