tf.config.experimental.get_visible_devices
Stay organized with collections
Save and categorize content based on your preferences.
Get the list of visible physical devices.
tf.config.experimental.get_visible_devices(
device_type=None
)
Returns a list of PhysicalDevice objects that are current marked as visible to
the runtime. Any visible devices will have LogicalDevices assigned to them
once the runtime is initialized.
The following example verifies all visible GPUs have been disabled:
physical_devices = config.experimental.list_physical_devices('GPU')
assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
# Disable all GPUS
tf.config.experimental.set_visible_devices([], 'GPU')
visible_devices = tf.config.experimental.get_visible_devices()
for device in visible_devices:
assert device.device_type != 'GPU'
Args |
device_type
|
(optional) Device types to limit query to.
|
Returns |
List of PhysicalDevice objects
|
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_visible_devices\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/config/experimental/get_visible_devices) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/framework/config.py#L350-L376) |\n\nGet the list of visible physical devices.\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_visible_devices`](/api_docs/python/tf/config/get_visible_devices)\n\n\u003cbr /\u003e\n\n tf.config.experimental.get_visible_devices(\n device_type=None\n )\n\nReturns a list of PhysicalDevice objects that are current marked as visible to\nthe runtime. Any visible devices will have LogicalDevices assigned to them\nonce the runtime is initialized.\n\nThe following example verifies all visible GPUs have been disabled: \n\n physical_devices = config.experimental.list_physical_devices('GPU')\n assert len(physical_devices) \u003e 0, \"Not enough GPU hardware devices available\"\n # Disable all GPUS\n tf.config.experimental.set_visible_devices([], 'GPU')\n visible_devices = tf.config.experimental.get_visible_devices()\n for device in visible_devices:\n assert device.device_type != 'GPU'\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|--------------------------------------------|\n| `device_type` | (optional) Device types to limit query to. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| List of PhysicalDevice objects ||\n\n\u003cbr /\u003e"]]