我在张量流上使用多 GPU。而且我对在同一范围内共享变量感到困惑。
根据https://github.com/tensorflow/models/blob/master/tutorials/image/cifar10/cifar10_multi_gpu_train.py
最简单的方法是:
for i in xrange(FLAGS.num_gpus):
with tf.device('/gpu:%d' % i):
tf.get_variable_scope().reuse_variables()
// and do sth.
但在我的理解中,至少第一个 GPU 必须创建变量,因为它没有变量可以重用。而且我还找到了一些代码,它为第一个 GPU 设置了重用 = False。
那么正确的方法是什么?