I've read that
os.environ["CUDA_VISIBLE_DEVICES"] = '' takes care that tensorflow will run on CPU and that
os.environ["CUDA_VISIBLE_DEVICES"] = '0' takes care that tensorflow will run on GPU 0.
How can I check, which device is used?
The code
# Creates a graph. 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 log_device_placement set to True. sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) # Runs the op. print(sess.run(c)) shows only the result
[[ 22. 28.] [ 49. 64.]] and no used device etc.