title: pytorch when do I need to use `.to(device)` on a model or tensor?
body: <p>I am new to Pytorch, but it seems pretty nice. My only question was when to use <code>tensor.to(device)</code> or <code>Module.nn.to(device)</code>.</p>
  <p>I was reading the <a href="https://pytorch.org/docs/stable/tensors.html#torch.Tensor.to" rel="noreferrer">documentation</a> on this topic, and it indicates that this method will move the tensor or model to the specified device. But I was not clear for what operations this is necessary, and what kind of errors I will get if I don't use <code>.to()</code> at the right time?</p>
  <p>For example, if I just create a tensor, I imagine that the tensor is stored in CPU accessible memory until I move the tensor to the GPU. Once the tensor is on the GPU, then the GPU will execute any mathematical operations on that tensor.</p>
  <p>However, do I have to worry about accidentally transferring the data tensor to the GPU while not transferring the model to the GPU? Will this just give me straight errors, or will it engage in a lot of expensive data transfer behind the scenes. This example is easy enough for me to test, but I was just wondering about other cases where it might not be so obvious.</p>
  <p>Any guidance would be helpful.</p>