As you said I changed my code to this and did not received warning again
Thank you

def to_var(x, volatile=False):
 with torch.no_grad():
     
     if torch.cuda.is_available():
         x = x.cuda()
 return x