Releasing memory after GPU usage

I am using a pretrained model for extracting features(tf.keras) for images during the training phase and running this in a GPU environment.
After the execution gets completed, i would like to release the GPU memory automatically without any manual intervention.

Have you tried with tf.keras.clear_session()?

I tried using tf.keras.clear_session() . Didn’t work though

Can you check clear_session() doesn't clear memory from GPU · Issue #9379 · keras-team/keras · GitHub ?

In this thread you can try to close CUDA in python with Numba