Here is a small working example:
class SubNet(nn.Module):
    def __init__(self, in_features, out_features):
        super(SubNet, self).__init__()
        self.linear1 = nn.Linear(in_features, out_features)
        
    def forward(self, x):
        x = self.linear1(x)
        return x

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.model1 = SubNet(10, 20)
        self.model2 = SubNet(20, 1)
        
    def forward(self, x):
        print("input size: {}".format(x.shape))
        x = self.model1(x)
        x = self.model2(x)
        return x
    

x = Variable(torch.randn(6, 10).cuda())

model = Net()
models = nn.DataParallel(model, device_ids=[0, 1])
models.cuda()
output = models(x)