-1

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 which lacks few methods like to(device) or set_default_device

Arjun Sankarlal
  • 2,655
  • 1
  • 9
  • 18

1 Answers1

1

You can use cuda() method of your tensor.

If you'd like to use specific device you could go with context manager, e.g.

with torch.cuda.device(device_index):
    t = torch.FloatTensor(1.).cuda()

For more specific information check documentation for version 0.3.0.

Szymon Maszke
  • 22,747
  • 4
  • 43
  • 83