0

The version of PyTorch: 1.4.0+cu100 When running

val_L= Variable(torch.from_numpy(val_L.copy()), volatile=True).cuda()

occurred:

UserWarning: volatile was removed and now has no essfet. Use 'with torch.no_grad():' insted.

So, how should I modify the code? Thank you very much!!!

hkzhang
  • 11
  • 1
  • 4
  • I modified the code to the following form: with torch.no_grad(): val_L = torch.from_numpy(val_L.copy()).cuda Is it right? – hkzhang Jul 01 '21 at 09:39

1 Answers1

0

this is what it is referring to

with torch.no_grad():
    val_L= Variable(torch.from_numpy(val_L.copy()))
Prajot Kuvalekar
  • 5,128
  • 3
  • 21
  • 32
  • Do you mean something like this: with torch.no_grad(): val_L= Variable(torch.from_numpy(val_L.copy())).cuda() – hkzhang Jul 01 '21 at 10:47