tensorflow tf.device

而一台机器上不同GPU的名称是不同的,第n个GPU在TensorFlow中的名称为/gpu:n。比如第一个GPU的名称为/gpu:0,第二个GPU名称为/gpu:1,以此类推。

这个还属可以把运算放在不同的设备上。


with tf.device('/cpu:0'):

   a= tf.constant([1.0, 2.0, 3.0], shape=[3], name='a')

   b= tf.constant([1.0, 2.0, 3.0], shape=[3], name='b')

with tf.device('/gpu:1'):

    c= a + b

你可能感兴趣的:(tensorflow tf.device)