How to check if the training of my model on tensorflow2.0 is using gpu acceleration

I have successfully run trained a model in tensorflow 2.0 using the fashion_mnist dataset and was wondering how could i possibly know if it was trained with the help of gpu acceleration ?

Upvotes: 1

Views: 1215

Answers (1)

Cesar
Cesar

Reputation: 585

In TensorFlow 2.0, you can use tf.config.experimental.list_physical_devices('GPU'):

import tensorflow as tf
gpu = tf.config.experimental.list_physical_devices('GPU')
   print("Name:", gpu.name, "  Type:", gpu.device_type)

If you have GPU installed, it outputs this:

Name: /physical_device:GPU:0   Type: GPU

And use the following code to check which GPU you are using:

from tensorflow.python.client import device_lib 
device_lib.list_local_devices()

Upvotes: 1

Related Questions