problem
Generally when you run tf, a single program often uses up all the memory block of the GPU.
But in fact, the program probably do not need such a big memory space.
improve proposals
By tf.ConfigProto().gpu_options.allow_growth=True
telling the program, just take the actual memory required to:
# ---------------- session ----------------
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)
If here the config.gpu_options.allow_growth
set False
, then the program will default to all memory fills entire card.