【问题标题】:running out of memory so quickly-tensorflow-gpu这么快就用完了内存-tensorflow-gpu
【发布时间】:2021-03-30 18:30:35
【问题描述】:

当我运行 https://github.com/cysmith/neural-style-tf 项目时,我的 gpu 在设备管理器图形中出现峰值,如下所示。

张量流:2.3.0 蟒蛇:3.7.9 CUDA:11.1 显卡:nvidia 840m

exact moment 然后它下降到零。

我得到“tensorflow 分配器 (gpu_0_bfc) 内存不足试图分配...”错误。

i dont know why 有很多关于它的话题,但我找不到适合我的答案。

【问题讨论】:

    标签: tensorflow memory gpu


    【解决方案1】:

    好像是内存分配的问题,能不能在导入TensorFlow后试试这个sn-p?

    gpus = tf.config.experimental.list_physical_devices('GPU')
    if gpus:
      try:
        for gpu in gpus:
          tf.config.experimental.set_memory_growth(gpu, True)
      except RuntimeError as e:
        print("Error: " + e)
    

    您也可以尝试在您的环境中将TF_FORCE_GPU_ALLOW_GROWTH 设置为TRUE

    这让您可以告诉 TensorFlow 根据使用情况慢慢增加从显卡分配的内存量。

    【讨论】:

      猜你喜欢
      • 2022-11-09
      • 2018-11-25
      • 1970-01-01
      • 1970-01-01
      • 2016-02-16
      • 1970-01-01
      • 2017-11-13
      • 2011-02-03
      • 2018-07-07
      相关资源
      最近更新 更多