- In order to find out which devices TensorFlow is using for which operations, we need to set a config in the session parameters that sets log_device_placement to True. When we run the script from the command line, we will see specific device placements, as shown in the following output:
import tensorflow as tf sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) 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) # Runs the op. print(sess.run(c))
- From the terminal, run the following command:
$python3 using_multiple_devices.py Device mapping: no known devices. I tensorflow/core/common_runtime/direct_session.cc:175] ...