December 2017
Intermediate to advanced
536 pages
14h 23m
English
We proceed with the recipe as follows:
# single GPU (baseline)import tensorflow as tf# place the initial data on the cpuwith tf.device('/cpu:0'): input_data = tf.Variable([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.], [10., 11., 12.]])b = tf.Variable([[1.], [1.], [2.]]) # compute the result on the 0th gpuwith tf.device('/gpu:0'): output = tf.matmul(input_data, b) # create a session and runwith tf.Session() as sess: sess.run(tf.global_variables_initializer()) print sess.run(output)
Read now
Unlock full access