How to convert ndarray to autograd variable in GPU format?

I am trying to do something like this,

data = torch.autograd.Variable(torch.from_numpy(nd_array))

It comes under the type as Variable[torch.FloatTensor], But I need Variable[torch.cuda.FloatTensor] also I want to do this in pytorch version 0.3.0

data = torch.autograd.Variable(torch.from_numpy(nd_array).cuda())

1 Like

Thanks @InnovArul, it worked :smiley: