Using the new methods you would write:
device = 'cuda' if torch.cuda.is_available() else 'cpu'
...
for batch_idx, (input, target) in enumerate(loader):
    input = input.to(device)
    target = target.to(device)
    ...

The volatile argument was replaces with the woth torch.no_grad(): statement.
You should just wrap your validation code into this statement to disable gradients:
with torch.no_grad():
    for batch_idx, (data, target) in enumerate(val_loader):
        ...