Calling Variable on G.data resets the loss tree. I think pytorch might throw an error if you tried that loss.
Maybe you can try the cholesky decomposition as mentioned in this post:

  
    
    
    How to calculate the determinant of a variable? 
  
  
    I have a variable a = Variable(torch.Tensor(5,5)), is there any way to calculate the determinant of that variable?