volatile was removed and now has no effect. Use with torch.no_grad(): instead
I have got this error, can you help me please?
This is my error in utils.py file
 content/gdrive/My Drive/DeepFakeDetection/utils.py:21: UserWarning:
 volatile was removed and now has no effect. Use with torch.no_grad():
 instead. return Variable(x, volatile=volatile)

And this is my code in utils.py file
 def to_var(x, volatile=False):
 
     if torch.cuda.is_available(): 
        x = x.cuda() 
     return Variable(x, volatile=volatile)

Thank you

I changed it to this:
def to_var(x, volatile=False):
&gt;     
&gt;     with torch.no_grad():
&gt;         
&gt;         if torch.cuda.is_available():
&gt;             x = x.cuda()
&gt;     return x

