Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

paddle v1.3.0 多节点运行时模型保存不完整

Open yxfGrace opened this issue 7 years ago • 11 comments

2个节点的cpu作业,pserver模式,用的是https://github.com/PaddlePaddle/Paddle/blob/v1.3.0/python/paddle/fluid/tests/book/notest_understand_sentiment.py 这个demo 保存模型后,两个节点中保存的模型不一致,其中一个节点的模型不完整,导致在load模型时报错 image 在输出中确实没有这个模型 同样的demo用paddle-v1.2.0是可以成功运行的 新版paddle的模型保存接口是否有变化呢?

yxfGrace avatar Feb 26 '19 07:02 yxfGrace

模型保存接口没有任何变化,可能是保存模型的时候其中一个节点被异常中断了,你可以再跑一次试试

kuke avatar Feb 26 '19 11:02 kuke

模型保存接口没有任何变化,可能是保存模型的时候其中一个节点被异常中断了,你可以再跑一次试试

可以稳定复现的呢 而且每次缺的模型都是相同的 所以应该不是随机问题

yxfGrace avatar Feb 26 '19 11:02 yxfGrace

是做增量还是做预测? 贴一下多机save/load的用法

seiriosPlus avatar Feb 27 '19 02:02 seiriosPlus

是做增量还是做预测? 贴一下多机save/load的用法 用的就是官网上的这个demo https://github.com/PaddlePaddle/Paddle/blob/v1.3.0/python/paddle/fluid/tests/book/notest_understand_sentiment.py 只是改成了多机运行的模式 save:

def train_loop(main_program):
        exe.run(fluid.default_startup_program())

        for pass_id in range(PASS_NUM):
            for data in train_data():
                cost_val, acc_val = exe.run(main_program,
                                            feed=feeder.feed(data),
                                            fetch_list=[cost, acc_out])
                print("cost=" + str(cost_val) + " acc=" + str(acc_val))
                if cost_val < 0.4 and acc_val > 0.8:
                    if save_dirname is not None:
                        fluid.io.save_inference_model(save_dirname, ["words"],
                                                      prediction, exe)
                    exe.close()
                    return
                if math.isnan(float(cost_val)):
                    sys.exit("got NaN loss, training failed.")
        raise AssertionError("Cost is too large for {0}".format(
            net_method.__name__))

load:

def infer(word_dict_len, use_cuda, save_dirname=None):
    if save_dirname is None:
        return

    place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
    exe = fluid.Executor(place)

    inference_scope = fluid.core.Scope()
    with fluid.scope_guard(inference_scope):
        # Use fluid.io.load_inference_model to obtain the inference program desc,
        # the feed_target_names (the names of variables that will be feeded
        # data using feed operators), and the fetch_targets (variables that
        # we want to obtain data from using fetch operators).
        [inference_program, feed_target_names,
         fetch_targets] = fluid.io.load_inference_model(save_dirname, exe)

yxfGrace avatar Feb 27 '19 02:02 yxfGrace

贴一下多机运行模式的写法, 1.3是有一点变化,我得确认一下你是怎么写的

seiriosPlus avatar Feb 27 '19 02:02 seiriosPlus

调用fluid.io.save_inference_model 的时候把 训练的main_program传进去看看呢?

seiriosPlus avatar Feb 27 '19 02:02 seiriosPlus

调用fluid.io.save_inference_model 的时候把 训练的main_program传进去看看呢?

还是一样的报错呢

yxfGrace avatar Feb 27 '19 03:02 yxfGrace

能把main_program的proto贴一下么, 把 load报错也贴一下

seiriosPlus avatar Feb 27 '19 03:02 seiriosPlus

能把main_program的proto贴一下么, 把 load报错也贴一下

def train_loop(main_program):
        exe.run(fluid.default_startup_program())

        for pass_id in range(PASS_NUM):
            for data in train_data():
                cost_val, acc_val = exe.run(main_program,
                                            feed=feeder.feed(data),
                                            fetch_list=[cost, acc_out])
                print("cost=" + str(cost_val) + " acc=" + str(acc_val))
                if cost_val < 0.4 and acc_val > 0.8:
                    if save_dirname is not None:
                        fluid.io.save_inference_model(save_dirname, ["words"],
                                                      prediction, exe,  main_program=main_program)
                    exe.close()
                    return
                if math.isnan(float(cost_val)):
                    sys.exit("got NaN loss, training failed.")
        raise AssertionError("Cost is too large for {0}".format(
            net_method.__name__))

报错: image

yxfGrace avatar Feb 27 '19 04:02 yxfGrace

proto这样打印:

        with open("xxx.proto", "w") as f:
            f.write(str(main_program))

seiriosPlus avatar Feb 27 '19 04:02 seiriosPlus

Since you haven't replied for more than a year, we have closed this issue/pr. If the problem is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up. 由于您超过一年未回复,我们将关闭这个issue/pr。 若问题未解决或有后续问题,请随时重新打开,我们会继续跟进。

paddle-bot-old avatar May 22 '20 10:05 paddle-bot-old