【问题标题】:tensorflow - Unexpected behavior of per_process_gpu_memory_fractiontensorflow - per_process_gpu_memory_fraction 的意外行为
【发布时间】: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


    【解决方案1】:

    根据我的实验,cudnn 和 cublas 上下文初始化似乎需要大约 228 mb 的内存。此外,cuda 上下文可能需要 50 到 118 mb。

    【讨论】:

      猜你喜欢
      • 2018-12-29
      • 2019-08-12
      • 2019-03-02
      • 2020-02-10
      • 2020-10-04
      • 2016-07-16
      • 2016-05-10
      • 2020-07-23
      • 2021-08-23
      相关资源
      最近更新 更多