I found that in the data handling part:
        if (self.cuda):
            X = X.cuda()
            Y = Y.cuda()
        yield Variable(X, requires_grad = False), Variable(Y, requires_grad = False)

put the whole training dataset into GPU, including all batches. The typical X shape would be
torch.Size([32, 500, 60, 2130])
32: batch_size
500: feature_num (since the first step is always CNN)
60: time_window
2130: id_num
time_window * id_num could be seen as a single image, so it can be simplified as an imageNet.
which may possess large GPU memory, and even more for intermediate variables while the model is training for back propagation. How can I modify this part to make the training dataset first in RAM, and while training, use single batch transfered from RAM to GPU?
Please, could someone help me with this problem?