The error is raised if your data or model are not pushed to the device, while one of them is.
You should make sure that both are on the GPU using:
model.to('cuda')
data = data.to('cuda')

as explained in this topic.