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

Function list_logical_devices

tensorflow/python/framework/config.py:389–414  ·  view source on GitHub ↗

Return a list of logical devices created by runtime. Logical devices may correspond to physical devices or remote devices in the cluster. Operations and tensors may be placed on these devices by using the `name` of the LogicalDevice. For example: ```python logical_devices = tf.config.

(device_type=None)

Source from the content-addressed store, hash-verified

387
388@tf_export('config.experimental.list_logical_devices')
389def list_logical_devices(device_type=None):
390 """Return a list of logical devices created by runtime.
391
392 Logical devices may correspond to physical devices or remote devices in the
393 cluster. Operations and tensors may be placed on these devices by using the
394 `name` of the LogicalDevice.
395
396 For example:
397
398 ```python
399 logical_devices = tf.config.experimental.list_logical_devices('GPU')
400 # Allocate on GPU:0
401 with tf.device(logical_devices[0].name):
402 one = tf.constant(1)
403 # Allocate on GPU:1
404 with tf.device(logical_devices[1].name):
405 two = tf.constant(2)
406 ```
407
408 Args:
409 device_type: (optional) Device type to filter by such as "CPU" or "GPU"
410
411 Returns:
412 List of LogicalDevice objects
413 """
414 return context.context().list_logical_devices(device_type=device_type)
415
416
417@tf_export('config.experimental.get_visible_devices')

Callers

nothing calls this directly

Calls 2

list_logical_devicesMethod · 0.80
contextMethod · 0.45

Tested by

no test coverage detected