含子图模型在多卡训练中报错
预测的graph是训练graph的一个子图,单卡可以正常跑,但是多卡在跑完训练过程中的第一次预测后就挂了,报错如下:

可以补充下下面的内容吧:
- 相关的模型代码,应该是写的方式不对
- 版本号
paddle版本用的是最新的develop分支编译的;(应该是你们的同学提供的) 关键代码:
def create_model(args,
pyreader_name,
bert_config,
num_labels,
mode):
if mode == "train":
pyreader = fluid.layers.py_reader(
capacity=50,
shapes=[
[-1, args.max_seq_len, 1],
[-1, args.max_seq_len, 1],
[-1, args.max_seq_len, 1],
[-1, args.max_seq_len, args.max_seq_len],
[-1, 1],
[-1, 1],
[-1, args.max_seq_len, 1],
[-1, args.max_seq_len, 1],
[-1, args.max_seq_len, 1],
[-1, args.max_seq_len, args.max_seq_len],
[-1, 1],
[-1, 1],
],
dtypes=[
'int64', 'int64', 'int64', 'float', 'int64', 'int64', 'int64',
'int64', 'int64', 'float', 'int64', 'int64'
],
lod_levels=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
name=pyreader_name,
use_double_buffer=True)
(pos_src_ids, pos_position_ids, pos_sent_ids, pos_self_attn_mask,
pos_labels, pos_next_sent_index, neg_src_ids, neg_position_ids,
neg_sent_ids, neg_self_attn_mask, neg_labels,
neg_next_sent_index) = fluid.layers.read_file(pyreader)
elif mode == "test":
pyreader = fluid.layers.py_reader(
capacity=50,
shapes=[
[-1, args.max_seq_len, 1],
[-1, args.max_seq_len, 1],
[-1, args.max_seq_len, 1],
[-1, args.max_seq_len, args.max_seq_len],
[-1, 1],
[-1, 1],
[-1, 1],
],
dtypes=[
'int64', 'int64', 'int64', 'float', 'int64', 'int64', 'int64'
],
lod_levels=[0, 0, 0, 0, 0, 0, 0],
name=pyreader_name,
use_double_buffer=True)
(pos_src_ids, pos_position_ids, pos_sent_ids, pos_self_attn_mask,
pos_labels, q_ids, pos_next_sent_index) = fluid.layers.read_file(pyreader)
#pos side
bert_pos = BertModel(
src_ids=pos_src_ids,
position_ids=pos_position_ids,
sentence_ids=pos_sent_ids,
self_attn_mask=pos_self_attn_mask,
config=bert_config)
cls_feats_pos = bert_pos.get_pooled_output(pos_next_sent_index)
cls_feats_pos = fluid.layers.dropout(
x=cls_feats_pos,
dropout_prob=0.1,
dropout_implementation="upscale_in_train")
score_pos = fluid.layers.fc(
input=cls_feats_pos,
size=num_labels,
param_attr=fluid.ParamAttr(
name="cls_out_w",
initializer=fluid.initializer.TruncatedNormal(scale=0.02)),
bias_attr=fluid.ParamAttr(
name="cls_out_b", initializer=fluid.initializer.Constant(0.)))
if mode == "test":
pos_probs = fluid.layers.sigmoid(score_pos)
q_ids.persistable = True
pos_labels.persistable = True
pos_probs.persistable = True
feed_targets_name = [
pos_src_ids.name, pos_position_ids.name, pos_sent_ids.name,
pos_self_attn_mask.name, pos_labels.name, q_ids.name, pos_next_sent_index.name
]
return pyreader, feed_targets_name, q_ids, pos_labels, pos_probs
#neg side
bert_neg = BertModel(
src_ids=neg_src_ids,
position_ids=neg_position_ids,
sentence_ids=neg_sent_ids,
self_attn_mask=neg_self_attn_mask,
config=bert_config)
cls_feats_neg = bert_neg.get_pooled_output(neg_next_sent_index)
cls_feats_neg = fluid.layers.dropout(
x=cls_feats_neg,
dropout_prob=0.1,
dropout_implementation="upscale_in_train")
score_neg = fluid.layers.fc(
input=cls_feats_neg,
size=1,
param_attr=fluid.ParamAttr(
name="cls_out_w",
initializer=fluid.initializer.TruncatedNormal(scale=0.02)),
bias_attr=fluid.ParamAttr(
name="cls_out_b", initializer=fluid.initializer.Constant(0.)))
score_pos = fluid.layers.sigmoid(score_pos)
score_neg = fluid.layers.sigmoid(score_neg)
ce_loss = fluid.layers.elementwise_add(
fluid.layers.fill_constant_batch_size_like(score_neg, score_neg.shape,
"float32", args.margin),
fluid.layers.elementwise_sub(score_neg, score_pos))
ce_loss = fluid.layers.elementwise_max(
ce_loss,
fluid.layers.fill_constant_batch_size_like(score_neg, score_neg.shape,
"float32", 0.0))
loss = fluid.layers.mean(ce_loss)
num_seqs = fluid.layers.create_tensor(dtype='int64')
probs = fluid.layers.softmax(
fluid.layers.concat(
input=[score_neg, score_pos], axis=1))
accuracy = fluid.layers.accuracy(
input=probs, label=pos_labels, total=num_seqs)
loss.persistable = True
probs.persistable = True
accuracy.persistable = True
num_seqs.persistable = True
loss.persistable = True
probs.persistable = True
accuracy.persistable = True
num_seqs.persistable = True
return pyreader, loss, probs, accuracy, num_seqs
啥代码?
已up,graph里面有一个sub-graph分支
你预测指的是中间 validate ? 外层是一次性跑 test,然后退出程序;还是一个进程会交替执行 train, test,两个分支都会跑到?
你预测指的是中间 validate ? 外层是一次性跑 test,然后退出程序;还是一个进程会交替执行 train, test,两个分支都会跑到?
预测指的是中间的validate过程,交替执行train、test。
@CAOYUHUI 首先计算图中有两个没有联通的子图 这是否符合你的预期? 能否提供一个可以复现的脚本
@CAOYUHUI 首先计算图中有两个没有联通的子图 这是否符合你的预期? 能否提供一个可以复现的脚本
私聊,我提供一个可复现的脚本~~感谢
已解决,是paddle版本的问题,更新paddle后就没有问题了。