title: How do I know whether an instance is stored on GPU with PyTorch?
body: <p>I'm learning PyTorch recently, and this question comes up.
  For example, if I have a net inheriting the &quot;torch.nn.Module&quot;.</p>
  <pre><code>class Net(torch.nn.Module):
      def __init__(self, something):
          super(net, self).__init__()
          self.p1=something
  
      def forward():
          pass
  
  net1=Net(123)
  net1.cuda()  ##Here I can't see what is changed.
  </code></pre>
  <p>Then how can I know whether net1 (and that something) is stored on GPU.</p>
  <p>I've read how the *.cuda() works, seems like let all the &quot;children&quot; run the *.cuda(). I tried to see what the &quot;children&quot; are. It seems the net1 above has no children.</p>