TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tf.config.experimental.set_memory_growth

TensorFlow 1 version View source on GitHub

Set if memory growth should be enabled for a PhysicalDevice.

Aliases:

tf.config.experimental.set_memory_growth(
    device,
    enable
)

Used in the guide:

A PhysicalDevice with memory growth set will not allocate all memory on the device upfront. Memory growth cannot be configured on a PhysicalDevice with virtual devices configured.

For example:

physical_devices = tf.config.experimental.list_physical_devices('GPU')
assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
tf.config.experimental.set_memory_growth(physical_devices[0], True)

Args:

  • device: PhysicalDevice to configure
  • enable: Whether to enable or disable memory growth