Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7051bbc2
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
未验证
提交
7051bbc2
编写于
8月 16, 2020
作者:
K
Kaipeng Deng
提交者:
GitHub
8月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix test_multiprocess_dataloader unittest. test=develop (#26241)
* fix test_multiprocess_dataloader unittest. test=develop
上级
9a6a4fbc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
14 deletion
+27
-14
python/paddle/fluid/dataloader/dataloader_iter.py
python/paddle/fluid/dataloader/dataloader_iter.py
+27
-14
未找到文件。
python/paddle/fluid/dataloader/dataloader_iter.py
浏览文件 @
7051bbc2
...
...
@@ -359,6 +359,9 @@ class _DataLoaderIterMultiProcess(_DataLoaderIterBase):
self
.
_outstanding_capacity
=
2
*
max
(
self
.
_num_workers
,
len
(
self
.
_places
))
# see _try_put_indices
self
.
_thread_lock
=
threading
.
Lock
()
# init workers and indices queues and put 2 indices in each indices queue
self
.
_init_workers
()
for
_
in
range
(
self
.
_outstanding_capacity
):
...
...
@@ -660,22 +663,32 @@ class _DataLoaderIterMultiProcess(_DataLoaderIterBase):
def
_try_put_indices
(
self
):
assert
self
.
_batches_outstanding
<=
self
.
_outstanding_capacity
,
\
"too many indices have been put to queue"
try
:
indices
=
next
(
self
.
_sampler_iter
)
except
StopIteration
:
return
# In multi-process mode for IterableDataset, _try_put_indices will
# be called both in main process(for our implement has blocking queue,
# and blocking queue read is in main process) and thread, which may
# cause error following error
# 1. "ValueError: generator already executing" in next(self._sampler_iter)
# 2. re-enter in increase _send_idx
# add a lock for threading save, for _try_put_indices is only a slight
# function which is not in data reading pipeline, this lock almost no
# influence on performance
with
self
.
_thread_lock
:
try
:
indices
=
next
(
self
.
_sampler_iter
)
except
StopIteration
:
return
for
i
in
range
(
self
.
_num_workers
):
worker_idx
=
next
(
self
.
_workers_idx_cycle
)
if
self
.
_worker_status
[
worker_idx
]:
break
else
:
return
for
i
in
range
(
self
.
_num_workers
):
worker_idx
=
next
(
self
.
_workers_idx_cycle
)
if
self
.
_worker_status
[
worker_idx
]:
break
else
:
return
self
.
_indices_queues
[
worker_idx
].
put
((
self
.
_send_idx
,
indices
))
self
.
_task_infos
[
self
.
_send_idx
]
=
(
worker_idx
,
)
self
.
_batches_outstanding
+=
1
self
.
_send_idx
+=
1
self
.
_indices_queues
[
worker_idx
].
put
((
self
.
_send_idx
,
indices
))
self
.
_task_infos
[
self
.
_send_idx
]
=
(
worker_idx
,
)
self
.
_batches_outstanding
+=
1
self
.
_send_idx
+=
1
def
__del__
(
self
):
self
.
_try_shutdown_all
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录