From e7dd6e05b6a637f19dfaedd86b49e59c94bbbe79 Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Fri, 22 Jan 2021 13:36:48 +0800 Subject: [PATCH] fix reader exit error (#2108) * fix reader exit error * fix commet --- dygraph/ppdet/data/reader.py | 12 ++++++++++++ dygraph/ppdet/modeling/backbones/vgg.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dygraph/ppdet/data/reader.py b/dygraph/ppdet/data/reader.py index f267d8aef..def98b962 100644 --- a/dygraph/ppdet/data/reader.py +++ b/dygraph/ppdet/data/reader.py @@ -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, diff --git a/dygraph/ppdet/modeling/backbones/vgg.py b/dygraph/ppdet/modeling/backbones/vgg.py index 7f770b59a..9d1b41ce6 100755 --- a/dygraph/ppdet/modeling/backbones/vgg.py +++ b/dygraph/ppdet/modeling/backbones/vgg.py @@ -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 -- GitLab