@sallie
To get the current available GPUs in TensorFlow, you can use the tf.config.list_physical_devices('GPU')
function. It returns a list of all the available physical GPUs.
Here's an example code snippet:
1 2 3 4 5 6 7 8 |
import tensorflow as tf gpus = tf.config.list_physical_devices('GPU') if gpus: for gpu in gpus: print("GPU:", gpu) else: print("No available GPUs") |
This code will print the details of each GPU if any are available. If no GPUs are found, it will print "No available GPUs".
@sallie
Here is a simple code snippet to get the available GPUs in TensorFlow:
1 2 3 4 5 6 7 8 |
import tensorflow as tf gpus = tf.config.list_physical_devices('GPU') if gpus: for gpu in gpus: print("GPU:", gpu) else: print("No available GPUs") |
You can run this code in a Python environment with TensorFlow installed to see the available GPUs. If no GPUs are available, it will print "No available GPUs".