Hello !
This code prints an array of nan  :
a = Variable(torch.zeros(3,3), requires_grad=True)
b = a.norm()
b.backward()
print a.grad

Have I done anything wrong ? Looks rather like a formula bug …
I have found a similar issue here, may be related …

  
    
    
    Nan in backward() if prod() is used 
  
  
    In torch.autograd._functions.reduce 
class Prod was implemented in a way that it produces nan gradient when zeros value is given. 
Beginning with the product of all input, the gradient is calculated by dividing that product by each input entry. 
When input entry is zero, this method returns ‘nan’ gradient. 
By replacing backward() function of Prod() class with 
    if self.dim is None:
        input, = self.saved_tensors
        zero_loc = (input==0).nonzero()
        if zero_loc.dim() == 0:
   …