Can't find the source of a “expected…cuda…but got…cpu” error

I’m struggling to find the source of a RuntimeError stating that a certain input that’s supposed to be on GPU is actually on CPU. I know this is usually a “you forgot to add a .cuda()” somewhere error, but I can’t seem to find what I’m missing…could use a code review from a practitioner more experienced with PyTorch.

Here’s a StackOverflow question with more details, include the model code.

Solution has been posted:

Pytorch requires your to do self.module_name = module for things to work correctly. It’s okay to keep them in a list. Just do something like setattr(self, 'emb_{}'.format(i), emb) for each step in that loop.