Limit Tensorflow GPU memory usage via environmental variable

Viewed 276

I am using a C++ library that internally uses Tensorflow, so I do not have access to session parameters.

When Tensorflow session is created one can limit GPU memory usage by setting per_process_gpu_memory_fraction value and allow growth flag (example in Python):

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

It is also possible to set global value for allow growth using environmental variable that will be used if this option is not specified in the tf.ConfigProto: export TF_FORCE_GPU_ALLOW_GROWTH=true in linux shell.

I wonder if there's an environmental variable for setting per_process_gpu_memory_fraction globally?

0 Answers
Related