Does .item() automatically move the data to the cpu?

No, you would detach the tensor (in case it has an Autograd history), push the data to the CPU, and transform it to a numpy array via:

preds = torch.randn(10, 10, requires_grad=True) # GPUTensors with Autograd history
preds_arr = preds.detach().cpu().numpy()
np_fun(preds_arr)
4 Likes