Is it working? I tried that with v1.6.



x = Variable(torch.Tensor([1, 2, 3, 4, 5, 6]), requires_grad= True)
y = Variable(torch.Tensor([2, 4, 6, 8, 10, 12]), requires_grad= False)
torch.autograd.grad(y, x)
Traceback (most recent call last):
File “”, line 1, in 
File “anaconda3/envs/updated/lib/python3.8/site-packages/torch/autograd/init.py”, line 190, in grad
return Variable._execution_engine.run_backward(
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn`



Same message with older versions.