How to clear memory after training

I have a 1060 6GB and after training the model about 4 gigabytes still remain occupied. I either need to do a pkill -u [username] and login again before I retrain the model. Is there any way that it clears itself or is there something I’m doing wrong ?

Are you seeing this zombie process after your script has finished?
Is your script crashing at some point?

No, the process does not crash. But I do see zombie processes.

Do you have a (small) reproducible code snippet so that we could have a look?