This is a different issue, now your data loading is not eating up all the RAM of your computer.
Now if the GPU is running out of memory as well, then the first thing to do is reduce the batch size to see when it fits on the gpu. If you have a GPU with a small amount of memory, you might only be able to use small models.