tf.config.experimental.set_memory_growth
Stay organized with collections
Save and categorize content based on your preferences.
Set if memory growth should be enabled for a PhysicalDevice.
tf.config.experimental.set_memory_growth(
device, enable
)
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
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.config.experimental.set_memory_growth\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/config/experimental/set_memory_growth) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/config.py#L434-L454) |\n\nSet if memory growth should be enabled for a PhysicalDevice.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.config.experimental.set_memory_growth`](/api_docs/python/tf/config/experimental/set_memory_growth)\n\n\u003cbr /\u003e\n\n tf.config.experimental.set_memory_growth(\n device, enable\n )\n\nA PhysicalDevice with memory growth set will not allocate all memory on the\ndevice upfront. Memory growth cannot be configured on a PhysicalDevice with\nvirtual devices configured.\n\n#### For example:\n\n physical_devices = tf.config.experimental.list_physical_devices('GPU')\n assert len(physical_devices) \u003e 0, \"Not enough GPU hardware devices available\"\n tf.config.experimental.set_memory_growth(physical_devices[0], True)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------|--------------------------------------------|\n| `device` | PhysicalDevice to configure |\n| `enable` | Whether to enable or disable memory growth |\n\n\u003cbr /\u003e"]]