MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / get_visible_devices

Function get_visible_devices

tensorflow/python/framework/config.py:418–443  ·  view source on GitHub ↗

Get the list of visible physical devices. 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 dis

(device_type=None)

Source from the content-addressed store, hash-verified

416
417@tf_export('config.experimental.get_visible_devices')
418def get_visible_devices(device_type=None):
419 """Get the list of visible physical devices.
420
421 Returns a list of PhysicalDevice objects that are current marked as visible to
422 the runtime. Any visible devices will have LogicalDevices assigned to them
423 once the runtime is initialized.
424
425 The following example verifies all visible GPUs have been disabled:
426
427 ```python
428 physical_devices = config.experimental.list_physical_devices('GPU')
429 assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
430 # Disable all GPUS
431 tf.config.experimental.set_visible_devices([], 'GPU')
432 visible_devices = tf.config.experimental.get_visible_devices()
433 for device in visible_devices:
434 assert device.device_type != 'GPU'
435 ```
436
437 Args:
438 device_type: (optional) Device types to limit query to.
439
440 Returns:
441 List of PhysicalDevice objects
442 """
443 return context.context().get_visible_devices(device_type)
444
445
446@tf_export('config.experimental.set_visible_devices')

Callers

nothing calls this directly

Calls 2

get_visible_devicesMethod · 0.80
contextMethod · 0.45

Tested by

no test coverage detected