Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
afcda610
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
404
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
afcda610
编写于
3月 27, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mge/data/dataloader): fix typo, import and refine the logic of plasma_store
GitOrigin-RevId: 7d169a52945e74802e08ddaaf4b578945cc8424d
上级
65432d3b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
7 deletion
+28
-7
python_module/megengine/data/_queue.py
python_module/megengine/data/_queue.py
+25
-5
python_module/megengine/data/dataloader.py
python_module/megengine/data/dataloader.py
+3
-2
未找到文件。
python_module/megengine/data/_queue.py
浏览文件 @
afcda610
...
...
@@ -16,6 +16,19 @@ import pyarrow.plasma as plasma
MGE_PLASMA_MEMORY
=
int
(
os
.
environ
.
get
(
"MGE_PLASMA_MEMORY"
,
4000000000
))
# 4GB
# Each process only need to start one plasma store, so we set it as a global variable.
# TODO: how to share between different processes?
MGE_PLASMA_STORE_MANAGER
=
None
def
_clear_plasma_store
():
# `_PlasmaStoreManager.__del__` will not ne called automaticly in subprocess,
# so this function should be called explicitly
global
MGE_PLASMA_STORE_MANAGER
if
MGE_PLASMA_STORE_MANAGER
is
not
None
:
del
MGE_PLASMA_STORE_MANAGER
MGE_PLASMA_STORE_MANAGER
=
None
class
_PlasmaStoreManager
:
def
__init__
(
self
):
...
...
@@ -34,11 +47,6 @@ class _PlasmaStoreManager:
self
.
plasma_store
.
kill
()
# Each process only need to start one plasma store, so we set it as a global variable.
# TODO: how to share between different processes?
MGE_PLASMA_STORE_MANAGER
=
_PlasmaStoreManager
()
class
PlasmaShmQueue
:
def
__init__
(
self
,
maxsize
:
int
=
0
):
r
"""Use pyarrow in-memory plasma store to implement shared memory queue.
...
...
@@ -51,6 +59,17 @@ class PlasmaShmQueue:
:param maxsize: maximum size of the queue, `None` means no limit. (default: ``None``)
"""
# Lazy start the plasma store manager
global
MGE_PLASMA_STORE_MANAGER
if
MGE_PLASMA_STORE_MANAGER
is
None
:
try
:
MGE_PLASMA_STORE_MANAGER
=
_PlasmaStoreManager
()
except
FileNotFoundError
as
e
:
raise
FileNotFoundError
(
"command 'plasma_store' not found in your $PATH!"
"Please make sure pyarrow installed and add into $PATH."
)
self
.
socket_name
=
MGE_PLASMA_STORE_MANAGER
.
socket_name
# TODO: how to catch the exception happened in `plasma.connect`?
...
...
@@ -100,6 +119,7 @@ class PlasmaShmQueue:
def
close
(
self
):
self
.
queue
.
close
()
self
.
disconnect_client
()
_clear_plasma_store
()
def
cancel_join_thread
(
self
):
self
.
queue
.
cancel_join_thread
()
python_module/megengine/data/dataloader.py
浏览文件 @
afcda610
...
...
@@ -17,12 +17,13 @@ import numpy as np
import
megengine
as
mge
from
..logger
import
get_logger
from
.collator
import
Collator
from
.dataset
import
Dataset
from
.sampler
import
Sampler
,
SequentialSampler
from
.transform
import
PseudoTransform
,
Transform
logger
=
mge
.
get_logger
(
__name__
)
logger
=
get_logger
(
__name__
)
MP_QUEUE_GET_TIMEOUT
=
5
...
...
@@ -167,7 +168,7 @@ class _SerialDataLoaderIter(_BaseDataLoaderIter):
class
_ParallelDataLoaderIter
(
_BaseDataLoaderIter
):
__initialzed
=
False
__initial
i
zed
=
False
def
__init__
(
self
,
loader
):
super
(
_ParallelDataLoaderIter
,
self
).
__init__
(
loader
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录