未验证 提交 e7dd6e05 编写于 作者: K Kaipeng Deng 提交者: GitHub

fix reader exit error (#2108)

* fix reader exit error
* fix commet
上级 5d7f09ed
......@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import copy
import traceback
import six
......@@ -32,6 +33,8 @@ from . import transform
from ppdet.utils.logger import setup_logger
logger = setup_logger('reader')
MAIN_PID = os.getpid()
class Compose(object):
def __init__(self, transforms, num_classes=81):
......@@ -73,6 +76,15 @@ class BatchCompose(Compose):
format(f, e, str(stack_info)))
raise e
# accessing ListProxy in main process (no worker subprocess)
# may incur errors in some enviroments, ListProxy back to
# list if no worker process start, while this `__call__`
# will be called in main process
global MAIN_PID
if os.getpid() == MAIN_PID and \
isinstance(self.output_fields, mp.managers.ListProxy):
self.output_fields = []
# parse output fields by first sample
# **this shoule be fixed if paddle.io.DataLoader support**
# For paddle.io.DataLoader not support dict currently,
......
......@@ -4,7 +4,7 @@ import paddle
import paddle.nn as nn
import paddle.nn.functional as F
from paddle import ParamAttr
from paddle.fluid.regularizer import L2Decay
from paddle.regularizer import L2Decay
from paddle.nn import Conv2D, MaxPool2D
from ppdet.core.workspace import register, serializable
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册