title: How to fix 'Input and hidden tensors are not at the same device' in pytorch
body: <p>When I want to put the model on the GPU, I get the following error:</p>
  <blockquote>
  <p>&quot;RuntimeError: Input and hidden tensors are not at the same device, found input tensor at cuda:0 and hidden tensor at cpu&quot;</p>
  </blockquote>
  <p>However, all of the above had been put on the GPU:</p>
  <pre><code>for m in model.parameters():
      print(m.device) #return cuda:0
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>if torch.cuda.is_available():
      model = model.cuda()
      test = test.cuda() # test is the Input
  </code></pre>
  <hr />
  <p>Windows 10 server<br />
  Pytorch 1.2.0 + cuda 9.2<br />
  cuda 9.2<br />
  cudnn 7.6.3 for cuda 9.2</p>