Execute a model on CPU and then GPU

After moving a model to CPU to execute a step, I would like to move it to GPU for the next steps. But when I do this, the weight remains on CPU. I am using .to() method. I see the error ‘RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same’

What might be going on?

Hi,
You are most probably just moving the inputs to CUDA but not the model --aka the weights. It might also be that the model initialization is faulty as you have used nn.parameters inside the ‘forward’ function. Can you please edit your original question with the model architectural code and the place where you are sending over the model to CUDA ?