tf.config.experimental.get_memory_growth
Stay organized with collections
Save and categorize content based on your preferences.
Get if memory growth is enabled for a PhysicalDevice
.
tf.config.experimental.get_memory_growth(
device
)
If memory growth is enabled for a PhysicalDevice
, the runtime initialization
will not allocate all memory on the device.
For example:
physical_devices = tf.config.list_physical_devices('GPU')
try:
tf.config.experimental.set_memory_growth(physical_devices[0], True)
assert tf.config.experimental.get_memory_growth(physical_devices[0])
except:
# Invalid device or cannot modify virtual devices once initialized.
pass
Args |
device
|
PhysicalDevice to query
|
Returns |
A boolean indicating the memory growth setting for the PhysicalDevice .
|
Raises |
ValueError
|
Invalid PhysicalDevice specified.
|
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.get_memory_growth\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/config/experimental/get_memory_growth) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/framework/config.py#L440-L466) |\n\nGet if memory growth is 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.get_memory_growth`](/api_docs/python/tf/config/experimental/get_memory_growth)\n\n\u003cbr /\u003e\n\n tf.config.experimental.get_memory_growth(\n device\n )\n\nIf memory growth is enabled for a `PhysicalDevice`, the runtime initialization\nwill not allocate all memory on the device.\n\n#### For example:\n\n physical_devices = tf.config.list_physical_devices('GPU')\n try:\n tf.config.experimental.set_memory_growth(physical_devices[0], True)\n assert tf.config.experimental.get_memory_growth(physical_devices[0])\n except:\n # Invalid device or cannot modify virtual devices once initialized.\n pass\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------|---------------------------|\n| `device` | `PhysicalDevice` to query |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A boolean indicating the memory growth setting for the `PhysicalDevice`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|-------------------------------------|\n| `ValueError` | Invalid `PhysicalDevice` specified. |\n\n\u003cbr /\u003e"]]