7

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.

sanna
  • 1,398
  • 5
  • 16
  • 24

2 Answers2

16

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

Andrew Pynch
  • 190
  • 1
  • 9
  • 3
    Thanks, I am getting `Please install GPU version of TF` with some other log info. But I have already installed tensorflow gpu, would you like to have a look at the screenshot? – sanna Apr 15 '19 at 14:33
  • please open you Tensorflow environment in the console and type ```python pip list ``` Then take a screenshot of all packages. – Andrew Pynch Apr 15 '19 at 14:48
  • 1
    Seemed like a restart solved the issue, sorry for wasting your time but thanks a lot for the help! – sanna Apr 15 '19 at 14:52
  • Same for you! Cheers! – sanna Apr 15 '19 at 15:36
1

try

 tf.debugging.set_log_device_placement(True) 

then run something from tensorflow like

a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)

then the console will print the device tf is running on enter image description here

Friseur
  • 103
  • 1
  • 7