【问题标题】:DSVM GPU runs out of memoryDSVM GPU 内存不足
【发布时间】:2018-07-10 17:52:37
【问题描述】:

我正在 DSVM Ubuntu 机器上开发一个 REST API Web 应用程序。服务器运行 Flask、Apache 和 Keras。

我正在使用具有 56GB RAM 和单个 K80 GPU 的 GPU 机器。

问题是,即使我的模型使用小批量进行预测,GPU 也会耗尽内存。

没有运行,12GB GPU 使用超过 10GB。也许这是因为 Apache 的问题。

运行nvidia-smi 显示以下内容:

|    0     38915      C   python  370MiB |

|    0     98378      C   /usr/sbin/apache2    10860MiB |

【问题讨论】:

    标签: apache keras gpu azure-dsvm


    【解决方案1】:

    我假设您正在为 Keras 使用 TensorFlow 后端。默认情况下,TensorFlow 会分配几乎所有的 GPU 内存,以减少潜在的内存碎片。从the TensorFlow guide to using the GPU,可以限制TensorFlow分配的总内存:

    import tensorflow as tf
    from keras.backend.tensorflow_backend import set_session
    config = tf.ConfigProto()
    config.gpu_options.per_process_gpu_memory_fraction = 0.3
    set_session(tf.Session(config=config))
    

    【讨论】:

      猜你喜欢
      • 2020-12-22
      • 2019-04-15
      • 1970-01-01
      • 2018-11-15
      • 1970-01-01
      • 2018-12-15
      • 2017-04-25
      • 2015-01-18
      • 2020-11-12
      相关资源
      最近更新 更多