Are you seeing this OOM error during training or after training and during validation / testing?
If the former case is true, are you seeing an increased memory usage on your GPU during training?
On the other hand, if you are seeing this issue after training, could you wrap your training, validation etc. in separate functions?
Python uses function scoping, so variables will be freed once you leave the scope (and don’t return the variable).