在我的两个系统(P40、CUDA9、CUDNN7)中,分别安装了 tf1.8 和 tf1.12,并且在 tf1.12 中运行的同一段代码几乎是 tf1.8 中分配的 gpu 内存的两倍。
我编写了以下代码来简化比较。此时在 tf1.8 中,分配了 1241MiB gpu 内存,在 tf1.12 中,分配了 737MiB gpu 内存。如何优化 tf 中的 gpu 内存分配?任何建议将不胜感激。
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
config.allow_soft_placement = True
a=tf.get_variable('a',(100,100))
b=tf.get_variable('b',(10000,10000))
sess=tf.Session(config=config)
sess.run(tf.global_variables_initializer())