import tensorflow as tf
gpu_device = tf.config.list_physical_devices('GPU')
if gpu_device:
print(" GPU is being utilized by TensorFlow")
for gpu in gpu_device:
print(f"- {gpu}")
else:print("TensorFlow is not using the GPU.")
To check whether Tensorflow is using GPU, you can verify by running the above code in the Python environment.
After executing the code check the logs for GPU Usage, when you run the code, TensorFlow will log the device placement in the console. Look for messages showing that operations are being executed on GPU
you can also monitor GPU usage in real-time using the nvidia-smi common in your terminal.
Bash Command: nvidia-smi