Can not send dataset to GPU


I am a newbies for ML. I started training MNIST dataset. I can send my model to GPU by using this code. # Returned… true

When I sent the dataset to GPU by this testing code.

for batch_idx, (data, target) in enumerate(train_loader):
if batch_idx == 100:

#Returned … cpu
#Returned … <class ‘torch.Tensor’>

Question: Why does “” still be on CPU?
Note: I use RTX30xx

The to() operation is not applied inplace on tensors (unlike on modules as it’s recursively applied on all submodules, parameters, and buffers internally), so you need to reassign the tensor:

x =
1 Like

Thank you very much , I got it :slight_smile: solved