What does 0 mean here for GPU?

I just read a document and have one question. Since it said set GPU as available physical device, then does 0 mean it only choose 1 GPU? or does it mean it does not use any GPU? Thanks!

Set GPU as available physical device

my_devices = tf.config.experimental.list_physical_devices(device_type=‘GPU’)[0]

tf.config.experimental.set_visible_devices(devices= my_devices, device_type=‘GPU’)

@Lara,

Welcome to the Tensorflow Forum,

my_devices = tf.config.experimental.list_physical_devices(device_type=‘GPU’)

This returns list of available GPU devices.

my_devices = tf.config.experimental.list_physical_devices(device_type=‘GPU’)[0]

This returns first GPU device from the list. You are accessing the element at index 0.

Note: You can use tf.config.list_physical_devices instead of tf.config.experimental.list_physical_devices

Thank you!

1 Like