Skip to content

Instantly share code, notes, and snippets.

@geogeorgiev
Created July 7, 2016 10:03
Show Gist options
  • Save geogeorgiev/9471e72e001adc9eb65fe3882b6c4c60 to your computer and use it in GitHub Desktop.
Save geogeorgiev/9471e72e001adc9eb65fe3882b6c4c60 to your computer and use it in GitHub Desktop.
Test GPU enabled Tensorflow Docker container
import tensorflow as tf
for d in ['/gpu:0']:
with tf.device(d):
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)
# Creates a session with allow_soft_placement and log_device_placement set
# to True.
sess = tf.Session(config=tf.ConfigProto(
allow_soft_placement=True, log_device_placement=True))
# Runs the op.
print sess.run(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment