Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • Paddle
  • Issue
  • #19184

P
Paddle
  • 项目概览

PaddlePaddle / Paddle
大约 2 年 前同步成功

通知 2325
Star 20933
Fork 5424
  • 代码
    • 文件
    • 提交
    • 分支
    • Tags
    • 贡献者
    • 分支图
    • Diff
  • Issue 1423
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 543
  • Wiki 0
    • Wiki
  • 分析
    • 仓库
    • DevOps
  • 项目成员
  • Pages
P
Paddle
  • 项目概览
    • 项目概览
    • 详情
    • 发布
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • Issue 1,423
    • Issue 1,423
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 543
    • 合并请求 543
  • Pages
  • 分析
    • 分析
    • 仓库分析
    • DevOps
  • Wiki 0
    • Wiki
  • 成员
    • 成员
  • 收起侧边栏
  • 动态
  • 分支图
  • 创建新Issue
  • 提交
  • Issue看板
已关闭
开放中
Opened 8月 13, 2019 by saxon_zh@saxon_zhGuest

单机多卡(或多CPU模式),异步读数据报错ValueError: Feed a list of tensor, the list should be the same size as places

Created by: QianShengWu

paddpaddle的单机多卡是不是异步读数据会出现问题,数据不一致还是冲突? 代码是百度的simnet,修改成异步读数据。

left = data.ops(name="left", shape=[1], dtype="int64", lod_level=1)
pos_right = data.ops(name="right", shape=[1], dtype="int64", lod_level=1)
neg_right = data.ops(name="neg_right", shape=[1], dtype="int64", lod_level=1)
left_feat, pos_score = net.predict(left, pos_right)
_, neg_score = net.predict(left, neg_right)
avg_cost = loss.compute(pos_score, neg_score)
        
reader = data_reader.get_reader(conf_dict, False, None)
py_reader = fluid.io.PyReader(feed_list=[left, pos_right, neg_right], capacity=640, use_double_buffer=True,
                                      iterable=True)

进行训练

batch_data = paddle.batch(reader, conf_dict["batch_size"], drop_last=False)
    py_reader.decorate_sample_list_generator(batch_data, places=place)

    for epoch_id in range(conf_dict["epoch_num"]):
        losses = []
        # Get batch data iterator
        start_time = time.time()
        total_loss = 0.0
        for iter, data in enumerate(py_reader()):
            avg_loss = parallel_executor.run(
                [avg_cost.name], feed=data)

出现错误如下

➜  paddle git:(master) ✗ export CPU_NUM=2
➜  paddle git:(master) ✗ sh run_train.sh 
{'net': {'module_name': 'bow', 'class_name': 'BOW', 'emb_dim': 128, 'bow_dim': 128, 'hidden_dim': 128}, 'loss': {'module_name': 'hinge_loss', 'class_name': 'HingeLoss', 'margin': 0.1}, 'optimizer': {'class_name': 'AdamOptimizer', 'learning_rate': 0.001, 'beta1': 0.9, 'beta2': 0.999, 'epsilon': 1e-08}, 'dict_size': 14522, 'task_mode': 'pairwise', 'train_file_path': 'data/small.train', 'test_file_path': 'data/small.test', 'result_file_path': 'result_bow_pairwise', 'epoch_num': 10, 'model_path': 'models/bow_pairwise', 'use_epoch': 0, 'batch_size': 64, 'num_threads': 4}
I0813 17:46:26.663134 69371328 parallel_executor.cc:329] The number of CPUPlace, which is used in ParallelExecutor, is 2. And the Program will be copied 2 copies
I0813 17:46:26.673501 69371328 build_strategy.cc:340] SeqOnlyAllReduceOps:0, num_trainers:1
Traceback (most recent call last):
  File "paddle_simnet.py", line 232, in <module>
    train(conf_dict)
  File "paddle_simnet.py", line 119, in train
    [avg_cost.name], feed=data)
  File "/usr/local/lib/python3.7/site-packages/paddle/fluid/parallel_executor.py", line 280, in run
    return_numpy=return_numpy)
  File "/usr/local/lib/python3.7/site-packages/paddle/fluid/executor.py", line 666, in run
    return_numpy=return_numpy)
  File "/usr/local/lib/python3.7/site-packages/paddle/fluid/executor.py", line 508, in _run_parallel
    "Feed a list of tensor, the list should be the same size as places"
ValueError: Feed a list of tensor, the list should be the same size as places

单GPU, CPU代码运行是正常的。

麻烦各位大佬看看,小白先谢了。

指派人
分配到
无
里程碑
无
分配里程碑
工时统计
无
截止日期
无
标识: paddlepaddle/Paddle#19184
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7