首页 > 解决方案 > 通过环境变量限制 TensorFlow GPU 内存使用

问题描述

我正在使用内部使用 Tensorflow 的 C++ 库,因此我无权访问会话参数。

创建 Tensorflow 会话时,可以通过设置per_process_gpu_memory_fraction值和allow growth标志来限制 GPU 内存使用(Python 中的示例):

memory_config = tf.ConfigProto(gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=0.3))
memory_config.gpu_options.allow_growth=True

如果未在: in linux shell 中指定此选项,也可以设置allow growth使用环境变量的全局值。tf.ConfigProtoexport TF_FORCE_GPU_ALLOW_GROWTH=true

per_process_gpu_memory_fraction我想知道是否有用于全局设置的环境变量?

标签: linuxtensorflow

解决方案


推荐阅读