Thank you very much Anton,
In fact, I was looking for a “pytorch 0.4.0”-style alternative this kind of code:
x = Variable(torch.randn(5, 5)*2, requires_grad=True).cuda()

because of the scaling factor 2, I can’t just write the one-liner you suggested. In the 0.4.0 documentation, it is not clear to me how to write this properly. In the init.py file in the pytorch repo, the initializations are done using the no_grad() function. Here, it would be:
x = torch.empty((5,5),requires_grad=True,device='cuda:0')
with torch.no_grad():
    x.normal_()
    x.mul_(2)

but maybe there is a better (proper one or two lines) way to do this. What about this way:
x = torch.randn(5,5).mul(2).to('cuda:0').requires_grad_()

cheers
y