tf.config.experimental.get_visible_devices
Получить список видимых физических устройств.
tf.config.experimental.get_visible_devices(
device_type=None
)
Возвращает список объектов PhysicalDevice, которые в данный момент помечены как видимые для среды выполнения. У всех видимых устройств будут назначены LogicalDevices, как только среда выполнения будет инициализирована.
Следующий пример проверяет, что все видимые GPU отключены:
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'
| Аргументы | |
|---|---|
device_type | (необязательно) Типы устройств, к которым ограничить запрос. |
| Возвращаемое значение | |
|---|---|
| Список объектов PhysicalDevice |
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/config/experimental/get_visible_devices