I’m using cuda 11 and a RTX 2070 graphic card. I have trained a few smaller data set without problem using similar code. This time I have a data set of a size 200,000X17 and got this error message:
CUDA out of memory. Tried to allocate 98.07 GiB (GPU 0; 8.00 GiB total capacity; 161.76 MiB already allocated; 6.29 GiB free; 188.00 MiB reserved in total by PyTorch)
My code:
class NNTrain(nn.Module):
    def __init__(self):
        super(NNTrain, self).__init__()
        self.l1 = nn.Linear(n, nodes)
        self.l5 = nn.Linear(nodes, 1)
    
    def forward(self, inputs):
        x = F.relu(self.l1(inputs))
        x = self.l5(x)
        return x

for j in range(l):
    X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, shuffle = True, random_state=j)
    X_train_tensor = torch.from_numpy(X_train).float().cuda()
    Y_train_tensor = torch.from_numpy(Y_train).float().cuda()
    X_test_tensor = torch.from_numpy(X_test).float().cuda()
    Y_test_tensor = torch.from_numpy(Y_test).float().cuda()
    
    epochs = 10
    LEARNING_RATE = 0.001

    model = NNTrain()
    model.cuda()
    optimizer = torch.optim.Adam(model.parameters(), lr = LEARNING_RATE)

    model.train()
    for i in range(epochs):
        optimizer.zero_grad()
        Y_pred = model(X_train_tensor)
        loss = nn.L1Loss()(Y_pred, Y_train_tensor)
        loss.backward()
        optimizer.step()
    print(loss)

Any help is greatly appreciated!