The CUDA context needs approx. 600-1000MB of GPU memory depending on the used CUDA version as well as device. I don’t know, if your prints worked correctly, as you would only use ~4MB, which is quite small for an entire training script (assuming you are not using a tiny model).