Hi team,
I have two data generator classes, one which loads all the data from a file onto memory thereafter feeds and another one which feeds batches from the file. My script tries the first approach and if the memory is not sufficient goes to approach two.

try:
loader = DataLoader1()
except RuntimeError as e:
loader = DataLoader2()

But once the RuntimeError,

RuntimeError: cuda runtime error (2) : out of memory at /pytorch/aten/src/THC/generic/THCTensorMath.cu:35

is raised by DataLoader1, DataLoader2 also raises the same error. Is there a way I can solve this?
Thank you.