import torch
from torch import nn
from torchvision import models
from torch.autograd import Variable
class TableModule(nn.Module):
    def __init__(self):
        super(TableModule, self).__init__()
        
    def forward(self, x, dim):
        y = torch.cat(x, dim)
        return y


class VGGkModule(nn.Module):
    def __init__(self):
        super(VGGkModule,self).__init__()
        self.layer1 = models.vgg16('pretrained=true')
        self.layer2 = models.vgg16('pretrained=true')
        self.layer3 = models.vgg16('pretrained=true')
        self.layer4 = models.vgg16('pretrained=true')
        self.layer5 = models.vgg16('pretrained=true')
     
    def forward(self,x):
        y1 = self.layer1(x[0])
        y2 = self.layer2(x[1])
        y3 = self.layer3(x[2])
        y4 = self.layer4(x[3])
        y5 = self.layer5(x[4])
        par = TableModule()
        rep = par([y1,y2,y3,y4,y5],1)
        return rep


class LinearModule(nn.Module):
    def __init__(self):
        super(LinearModule,self).__init__()
        self.layer1 = nn.Linear(5000,1000)
    def forward(self,x):
        net = VGGkModule()
        x1 = net(x)
        y = self.layer1(x1)
        return y


class ParallelModule(nn.Module):
    def __init__(self):
        super(ParallelModule, self).__init__()
        self.layer1 = models.vgg16('pretrained=true')
        self.layer2 = LinearModule()        
    def forward(self, x):
        y1 = self.layer1(x[0])
        y2 = self.layer2(x[1:6])
        par = TableModule()
        y  = par([y1,y2],1)
        return y


class ProjModule(nn.Module):
    def __init__(self):
        super(ProjModule,self).__init__()
        self.layer1 = nn.Linear(2000,1000)
    def forward(self,x):
        net = ParallelModule()
        x1 = net(x)
        print 'Done1'
        y = self.layer1(x1)
        return y


inp = Variable(torch.rand(6,1,3,224,224))
net = ProjModule()
net.cuda()
output = net(inp.cuda())


I want to convert above code to gpu version but it is throwing a lot of errors by just converting net to cuda and porting inp to gpu using:
inp= torch.rand(6,3,224,224).cuda()
Please tell the solution to port it to gpu.
As well how shall I update this code to accomodate batch size?