Pytorch 0.2 code error

pytorch 0.2 version cuda8.0
the code:
inputs, targets = inputs.to(device), targets.to(device)
show error:
AttributeError: ‘torch.FloatTensor’ object has no attribute ‘to’

How do I modify the code?

PyTorch 0.2 is really old by now and the .to() operation was introduced in newer version. I would recommend to update to the latest version. You’ll find the install instructions here.

If that’s not possible for whatever reason, you could use .cuda() and .cpu() instead.