I have created a model class like this:
class model_parallel(nn.Module):
   def __init__(self):
      super().__init__()
      sub_net_1 = models.resnet50(True)
      # sub_net_1 = torch.nn.Sequential(*(list(sub_net_1.children())[:-3]))
      for param in sub_net_1.parameters():
         param.requires_grad = False
      sub_net_2 = nn.Sequential(nn.Linear(in_features=1000, out_features=500,bias=True),
      nn.ReLU(),
      nn.Linear(in_features=500, out_features=100,bias=True),
      nn.ReLU(),
      nn.Linear(in_features=100, out_features=67,bias=True))
      self.sub_network1 = sub_net_1.cuda(0)
      self.sub_network2 = sub_net_2.cuda(1)

   def forward(self, x):
      x = x.cuda(0)
      x = self.sub_network1(x)
      # print(x.shape)
      x = x.cuda(1)
      x = self.sub_network2(x)
      return x

However, I am getting

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1! (when checking argument for argument mat1 in method wrapper_addmm)

at

x = self.sub_network2(x)

What am I doing wrong here?