DataParallel backend problem

Hi All,
How are you?
I have recently installed two new GPUs and wanted to test them so I tried to run the cifar10 tutorial notebook and the following error came up:

RuntimeError: Expected object of backend CUDA but got backend CPU for argument #2 'target'

I thought the problem would be the assignment of the labels and inputs to the GPUs but I have done it (see the attached images below) I also checked that both of the GPUs are detectable both with nvidia-smi and torch.cuda.device_count()

Maybe the problem is elsewhere? with the torch.nn.DataParallel?

Thank you very much for your help.

Try changing

inputs.to(device)
labels.to(device)

to

inputs = inputs.to(device)
labels = labels.to(device)

thank you it’s actually works!