I have a neural network that consists of 3 convolutional layers, and 2 fully connected layers. The input data is of size 5194 * 4 * 256 * 256. I know this amount of data is huge, and GPUs will definitely not have enough space to hold this amount of data. So I instead defined the following function to sequentially process this amount of data:
def net_forward(in_Var, net, part=10):
    in_Var_ls = []
    for i in range(part-1):
        in_Var_ls.append(in_Var[int(in_Var.size()[0]/part*i):int(in_Var.size()[0]/part*(i+1)),:])
    in_Var_ls.append(in_Var[int(in_Var.size()[0]/part*(part-1)):,:])
    res1, res2 = net(in_Var_ls[0])
    for i in range(1, part):
        out1, out2 = net(in_Var_ls[i])
        res1 = torch.cat([res1, out1], dim=0)
        res2 = torch.cat([res2, out2], dim=0)
    return res1, res2

However, I still got the run out of memory error. What should I do?