Skip to content

Instantly share code, notes, and snippets.

@chaser92
Last active February 13, 2017 11:41
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 chaser92/5e5ba955d0063a878ea59e1633fda994 to your computer and use it in GitHub Desktop.
Save chaser92/5e5ba955d0063a878ea59e1633fda994 to your computer and use it in GitHub Desktop.
import tensorflow as tf
# just to verify they're installed
import pandas
import matplotlib
import scipy
import numpy
# With CPU
with tf.Session() as sess:
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul(matrix1, matrix2)
result = sess.run([product])
print(result)
# With GPU
with tf.Session() as sess:
with tf.device("/gpu:0"):
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul(matrix1, matrix2)
result = sess.run([product])
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment