When you use the with torch.no_grad() statement, everything written inside it will not require any grads, so you just don’t have to use volatile at all.
There are a bunch of old stuff in that code that you should check. For example, you should not use Variable at all, and the .cuda() function I think it should be replaced by a .to(device) call.
Check out the migration guidelines 41 for pytorch 0.4.0