When iterating over the data in the dataloader, I got the RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
My code still runs on an older computer (python 3.7, cuda 10, pytorch 1.4.0), but doesn’t work with my new laptop (python 3.8, cuda 11.1, pytorch 1.9.1).
When debugging, it seems to give a problem in the transforms.Normalize(means, stds) function. the mean and std are tensors on cuda (have been checking it), so it must be the data itself.
I’m loading my data with datasets.ImageFolder(path, transforms=transforms).
Does anyone knows what I should do to fix the error in this newer version?