tf.config.get_logical_device_configuration
Stay organized with collections
Save and categorize content based on your preferences.
Get the virtual device configuration for a tf.config.PhysicalDevice
.
tf.config.get_logical_device_configuration(
device
)
Returns the list of tf.config.LogicalDeviceConfiguration
objects previously configured by a call to
tf.config.set_logical_device_configuration
.
For example:
physical_devices = tf.config.list_physical_devices('CPU')
assert len(physical_devices) == 1, "No CPUs found"
configs = tf.config.get_logical_device_configuration(
physical_devices[0])
try:
assert configs is None
tf.config.set_logical_device_configuration(
physical_devices[0],
[tf.config.LogicalDeviceConfiguration(),
tf.config.LogicalDeviceConfiguration()])
configs = tf.config.get_logical_device_configuration(
physical_devices[0])
assert len(configs) == 2
except:
# Cannot modify virtual devices once initialized.
pass
Args |
device
|
PhysicalDevice to query
|
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. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.config.get_logical_device_configuration\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/framework/config.py#L802-L840) |\n\nGet the virtual device configuration for a [`tf.config.PhysicalDevice`](../../tf/config/PhysicalDevice).\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.config.experimental.get_virtual_device_configuration`](https://www.tensorflow.org/api_docs/python/tf/config/get_logical_device_configuration)\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_virtual_device_configuration`](https://www.tensorflow.org/api_docs/python/tf/config/get_logical_device_configuration), [`tf.compat.v1.config.get_logical_device_configuration`](https://www.tensorflow.org/api_docs/python/tf/config/get_logical_device_configuration)\n\n\u003cbr /\u003e\n\n tf.config.get_logical_device_configuration(\n device\n )\n\nReturns the list of [`tf.config.LogicalDeviceConfiguration`](../../tf/config/LogicalDeviceConfiguration)\nobjects previously configured by a call to\n[`tf.config.set_logical_device_configuration`](../../tf/config/set_logical_device_configuration).\n\n#### For example:\n\n physical_devices = tf.config.list_physical_devices('CPU')\n assert len(physical_devices) == 1, \"No CPUs found\"\n configs = tf.config.get_logical_device_configuration(\n physical_devices[0])\n try:\n assert configs is None\n tf.config.set_logical_device_configuration(\n physical_devices[0],\n [tf.config.LogicalDeviceConfiguration(),\n tf.config.LogicalDeviceConfiguration()])\n configs = tf.config.get_logical_device_configuration(\n physical_devices[0])\n assert len(configs) == 2\n except:\n # 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| List of [`tf.config.LogicalDeviceConfiguration`](../../tf/config/LogicalDeviceConfiguration) objects or `None` if no virtual device configuration has been set for this physical device. ||\n\n\u003cbr /\u003e"]]