Is it possible to change the default Session configuration, either within Python or by setting environment variables, etc.?
Specifically I'd like
with tf.Session() as sess:
...
to use up much less memory when I'm running small side tests in parallel to other jobs. So I'd the above to behave the same as
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.1)
config = tf.ConfigProto(gpu_options=gpu_options)
with tf.Session(config=config) as sess:
...
Don't think there's a way to set process-wide default, but here's the pattern I use.
def create_session():
config = tf.ConfigProto(log_device_placement=True)
config.gpu_options.per_process_gpu_memory_fraction=0.3 # don't hog all vRAM
sess = tf.InteractiveSession("", config=config)
return sess
sess=create_session()
a=tf.constant(1)
b=tf.constant(2)
sess.run([a+b])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With