The following line
x = x - 0.1 * x.grad

doesn’t modify the tensor originally referenced by the variable x, it creates a new tensor and changes the reference x to point to the new tensor. That is why x.grad disappears.
Try replacing the above line with x -= 0.1 * x.grad in order to modify the contents of x instead of redefining x.
The usual way of zeroing the gradients is by doing one of optimizer.zero_grad() or model.zero_grad().
Redefining x is probably also the cause of the error complaining about the tuple being volatile. I think the reason is that x no longer references the Variable declared with requires_grad=True but a Variable calculated from the original value. Variables that are the result of calculations are not considered to be leaf variables and they can’t require_grad nor do they have a .grad attribute.