From f89b256d412f16ef308ff76831563f928f5bb621 Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Fri, 5 Jul 2019 13:25:38 +0800 Subject: [PATCH] check gpu for ppdet/yolov3 and update ppdet MODEL_ZOO (#2730) * check gpu for ppdet/yolov3 * add random shape descp in MODEL_ZOO * refine doc * not use core --- README.md | 2 ++ docs/MODEL_ZOO.md | 8 +++++--- ppdet/utils/check.py | 47 ++++++++++++++++++++++++++++++++++++++++++++ tools/eval.py | 4 ++++ tools/infer.py | 4 ++++ tools/train.py | 4 ++++ 6 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 ppdet/utils/check.py diff --git a/README.md b/README.md index 306f47456..f4a15f5fb 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ Advanced Features: - [x] **Modulated Deformable Convolution**: pretrained models to be released. - [x] **Deformable PSRoI Pooling**: pretrained models to be released. +**NOTE:** Synchronized batch normalization can only be used on multiple GPU devices, can not be used on CPU devices or single GPU device. + ## Model zoo diff --git a/docs/MODEL_ZOO.md b/docs/MODEL_ZOO.md index fdd8f40e6..81821d640 100644 --- a/docs/MODEL_ZOO.md +++ b/docs/MODEL_ZOO.md @@ -67,8 +67,10 @@ The backbone models pretrained on ImageNet are available. All backbone models ar | ResNet34 | 416 | 8 | 270e | 34.3 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) | | ResNet34 | 320 | 8 | 270e | 31.4 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) | -**NOTE**: Yolo v3 trained in 8 GPU with total batch size as 64 and trained 270 epoches. Yolo v3 training data augmentations: mixup, -randomly color distortion, randomly cropping, randomly expansion, randomly interpolation method, randomly flippling. +**NOTE**: Yolo v3 is trained in 8 GPU with total batch size as 64 and trained 270 epoches. Yolo v3 training data augmentations: mixup, +randomly color distortion, randomly cropping, randomly expansion, randomly interpolation method, randomly flippling. Yolo v3 used randomly +reshaped minibatch in training, inferences can be performed on different image sizes with the same model weights, and we provided evaluation +results of image size 608/416/320 above. ### RetinaNet @@ -85,5 +87,5 @@ randomly color distortion, randomly cropping, randomly expansion, randomly inter | :----------- | :--: | :-----: | :-----: | :----: | :-------: | | MobileNet v1 | 300 | 32 | 120e | 73.2 | [model](https://paddlemodels.bj.bcebos.com/object_detection/ssd_mobilenet_v1_voc.tar) | -**NOTE**: SSD trained in 2 GPU with totoal batch size as 64 and trained 120 epoches. SSD training data augmentations: randomly color distortion, +**NOTE**: SSD is trained in 2 GPU with totoal batch size as 64 and trained 120 epoches. SSD training data augmentations: randomly color distortion, randomly cropping, randomly expansion, randomly flipping. diff --git a/ppdet/utils/check.py b/ppdet/utils/check.py new file mode 100644 index 000000000..9e816eaad --- /dev/null +++ b/ppdet/utils/check.py @@ -0,0 +1,47 @@ +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +import sys + +import paddle.fluid as fluid + +import logging +logger = logging.getLogger(__name__) + +__all__ = ['check_gpu'] + + +def check_gpu(use_gpu): + """ + Log error and exit when set use_gpu=true in paddlepaddle + cpu version. + """ + err = "Config use_gpu cannot be set as true while you are " \ + "using paddlepaddle cpu version ! \nPlease try: \n" \ + "\t1. Install paddlepaddle-gpu to run model on GPU \n" \ + "\t2. Set use_gpu as false in config file to run " \ + "model on CPU" + + try: + if use_gpu and not fluid.is_compiled_with_cuda(): + logger.error(err) + sys.exit(1) + except Exception as e: + pass + diff --git a/tools/eval.py b/tools/eval.py index a8feac1fd..b35de274b 100644 --- a/tools/eval.py +++ b/tools/eval.py @@ -24,6 +24,7 @@ import paddle.fluid as fluid from ppdet.utils.eval_utils import parse_fetches, eval_run, eval_results import ppdet.utils.checkpoint as checkpoint from ppdet.utils.cli import ArgsParser +from ppdet.utils.check import check_gpu from ppdet.modeling.model_input import create_feed from ppdet.data.data_feed import create_reader from ppdet.core.workspace import load_config, merge_config, create @@ -46,6 +47,9 @@ def main(): merge_config(FLAGS.opt) + # check if set use_gpu=True in paddlepaddle cpu version + check_gpu(cfg.use_gpu) + if cfg.use_gpu: devices_num = fluid.core.get_cuda_device_count() else: diff --git a/tools/infer.py b/tools/infer.py index f351db4c9..c70ce0501 100644 --- a/tools/infer.py +++ b/tools/infer.py @@ -30,6 +30,7 @@ from ppdet.data.data_feed import create_reader from ppdet.utils.eval_utils import parse_fetches from ppdet.utils.cli import ArgsParser +from ppdet.utils.check import check_gpu from ppdet.utils.visualizer import visualize_results import ppdet.utils.checkpoint as checkpoint @@ -109,6 +110,9 @@ def main(): merge_config(FLAGS.opt) + # check if set use_gpu=True in paddlepaddle cpu version + check_gpu(cfg.use_gpu) + if 'test_feed' not in cfg: test_feed = create(main_arch + 'TestFeed') else: diff --git a/tools/train.py b/tools/train.py index 718a46b7b..c12906748 100644 --- a/tools/train.py +++ b/tools/train.py @@ -43,6 +43,7 @@ from ppdet.data.data_feed import create_reader from ppdet.utils.eval_utils import parse_fetches, eval_run, eval_results from ppdet.utils.stats import TrainingStats from ppdet.utils.cli import ArgsParser +from ppdet.utils.check import check_gpu import ppdet.utils.checkpoint as checkpoint from ppdet.modeling.model_input import create_feed @@ -62,6 +63,9 @@ def main(): merge_config(FLAGS.opt) + # check if set use_gpu=True in paddlepaddle cpu version + check_gpu(cfg.use_gpu) + if cfg.use_gpu: devices_num = fluid.core.get_cuda_device_count() else: -- GitLab