错误:
多GPU设置时出现如下错误:ValueError: Variable E_conv0/w/Adam/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?
原因:
代码中有tf.get_variable_scope().reuse_variables()
,但却缺少上下文管理的APItf.varibale_scope()
.
解决方法:
在设置GPU的位置添加如下命令:with tf.variable_scope(tf.get_variable_scope()) as scope:
with tf.variable_scope(tf.get_variable_scope()) as scope:
for i in range(args.num_gpus):
with tf.device('gpu:%d' % i):
with tf.name_scope("%s_%d" % ('Tower', i)):
...
tf.get_variable_scope().reuse_variables()
参考:https://blog.csdn.net/u012436149/article/details/73555017