I have a numpy array which I would like to shift to gpu. I used the method: from_numpy(numpy_array).float().to(device)
. However, I get the following error:
To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor)
This warning doesn’t make sense as .clone()
method is not available for a numpy array. How can I move the said numpy array into a tensor on GPU?