【发布时间】:2018-09-10 19:24:40
【问题描述】:
我试图将 gpu 内存使用量限制为 gpu 内存的 10%,但根据 nvidia-smi,以下程序使用了大约 13% 的 gpu。这是预期的行为吗?如果是预期行为,那么另外大约 3-4% 来自什么?
from time import sleep
i = tf.constant(0)
x = tf.constant(10)
r = tf.add(i,x)
# Use at most 10% of gpu memory, I expect this to set a hard limit
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=.1)
# sleep is used to see what nvidia-smi says for gpu memory usage,
# I expect that it will be at most 10% of gpu memory (which is 1616.0 mib for my gpu)
# but instead I see the process using up to 2120 mib
with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:
sess.run(r);
sleep(10)
有关我的环境和 gpu 的更多详细信息,请参阅此 github 问题:https://github.com/tensorflow/tensorflow/issues/22158
【问题讨论】:
标签: python-3.x tensorflow memory nvidia