如文档中所述 ,您可以使用tf.device('/gpu:id')
指定默认设备以外的设备。
# This will use the second GPU on your system
with tf.device('/gpu:1'):
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)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print sess.run(c)
0
根据文档,默认GPU是ID最低的GPU:
是否可以从命令行或一行代码更改此默认设置?