Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check whether Tensorflow is running on GPU

Tags:

tensorflow

enter image description hereI have read many questions and "guides" on how to understand if Tensorflow is running on GPU but I am still quite confused.

I have taken a screenshot of my session and I would like to understand what is going on, and if Tensorflow is running on GPU or CPU.

like image 264
sanna Avatar asked Apr 15 '19 14:04

sanna


People also ask

Does TensorFlow automatically run on GPU?

If a TensorFlow operation has both CPU and GPU implementations, TensorFlow will automatically place the operation to run on a GPU device first. If you have more than one GPU, the GPU with the lowest ID will be selected by default. However, TensorFlow does not place operations into multiple GPUs automatically.

How can I tell if keras is using my GPU?

Checking Your GPU Availability With Keras The easiest way to check if you have access to GPUs is to call tf. config. experimental. list_physical_devices('GPU').


1 Answers

Roberto, try this

import tensorflow as tf
if tf.test.gpu_device_name():
    print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
else:
    print("Please install GPU version of TF")

the output should be

Default GPU Device: /device:GPU:0

GPU 0 is your GTX 860m

like image 186
Andrew Pynch Avatar answered Sep 17 '22 18:09

Andrew Pynch