Error: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
I am trying to train a DNN model using pytorch, and I want to use GPU to train my model. I am able to successfully copy my model to the GPU using model.to(device), where device = cuda:0.
However, the standard methods for copying input to the GPU, (RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same), that is, X.to(device) and X.cuda() does not give me the desired output. Following is the method I am currently implementing:
def train_loop(self, dataloader, device):
    size = len(dataloader.dataset)
    for batch, (X, y) in enumerate(dataloader):
        # Compute prediction and loss
        print(device)
        X.to(device)
        print(X.is_cuda)
        y.to(device)
        
        pred = self.model(X)
        loss = self.loss_fn(pred, y)

On printing the device value print(device) it shows as: cuda:0. But when I run print(X.is_cuda) it returns false. (Screenshot attached below).

Please let me know where I am going wrong. Thank you!

X.to(device) does nothing.
change it to:
x=x.to(device)

Of course this should be done to any parameter\variable you want on the GPU
