Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To retrieve the currently available GPUs in TensorFlow, you can use the tf.config.list_physical_devices('GPU') function. The code to retrieve the available GPUs is as follows:

import tensorflow as tf

gpus = tf.config.list_physical_devices('GPU')
print("Number of GPUs available: ", len(gpus))
for gpu in gpus:
    print("GPU Name:", gpu.name)

This will output the number of available GPUs and their names.