RuntimeError: Expected object of type CPUFloatType but found type CUDAFloatType for argument #2 'weight'

RuntimeError: Expected object of type CPUFloatType but found type CUDAFloatType for argument #2 'weight’
deleted

Check if your model and data are on the same device.

This Error may be caused by, for example, the mode is on gpu (model.cuda()) while input data is on cpu.

1 Like

Agree with zeakey. In addition, I just want to add that we can use x.is_cuda where x is the tensor of interest to check whether it is on GPU or not.