Skip to content

Instantly share code, notes, and snippets.

@lucgiffon
Created September 30, 2019 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucgiffon/bfb48fee760cd4525cf91fc5e5b9740f to your computer and use it in GitHub Desktop.
Save lucgiffon/bfb48fee760cd4525cf91fc5e5b9740f to your computer and use it in GitHub Desktop.
Verify if tensorflow is capable of using a GPU
"""https://stackoverflow.com/a/43703735/4803860"""
import tensorflow as tf
with tf.device('/gpu:0'):
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)
with tf.Session() as sess:
print (sess.run(c))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment