I am fitting a model in a for loop, but I am getting an error that my GPU's memory is full. I am using Keras in Anaconda Spyder IDE. My GPU is a Asus GTX 1060 6gb.
I have also used codes like: K.clear_session()
, gc.collect()
, tf.reset_default_graph()
, del custom_model but none of them worked.
GPU properties say's 98% of memory is full:
Nothing flush GPU memory except numba.cuda.close()
but will not allow me to use my GPU again. The only way to clear it is restarting kernel and rerun my code.
I am looking for any script code to add my code allow me to use my code in for loop and clear GPU in every loop.