The best way to check is close all the other applications running. Then run watch nvidia-smi in one terminal and in the other one run your code. Then check how the gpu memory is changing. Secondly checkout your batch size if your GPU can actually fit those number of images.