From 0cec70bd22b1a478079ab46cf3bd1960f2a463bf Mon Sep 17 00:00:00 2001 From: USTCKAY <1136780339@qq.com> Date: Thu, 20 Oct 2022 13:40:19 +0800 Subject: [PATCH] [CustomDevice]add support for custom NPU, test=develop --- ppcls/engine/engine.py | 2 +- ppcls/static/train.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) mode change 100644 => 100755 ppcls/engine/engine.py mode change 100644 => 100755 ppcls/static/train.py diff --git a/ppcls/engine/engine.py b/ppcls/engine/engine.py old mode 100644 new mode 100755 index 95f26405..2148fc50 --- a/ppcls/engine/engine.py +++ b/ppcls/engine/engine.py @@ -100,7 +100,7 @@ class Engine(object): # set device assert self.config["Global"][ - "device"] in ["cpu", "gpu", "xpu", "npu", "mlu"] + "device"] in ["cpu", "gpu", "xpu", "npu", "mlu", "ascend"] self.device = paddle.set_device(self.config["Global"]["device"]) logger.info('train with paddle {} and device {}'.format( paddle.__version__, self.device)) diff --git a/ppcls/static/train.py b/ppcls/static/train.py old mode 100644 new mode 100755 index 86e83249..14eb661e --- a/ppcls/static/train.py +++ b/ppcls/static/train.py @@ -92,9 +92,10 @@ def main(args): use_xpu = global_config.get("use_xpu", False) use_npu = global_config.get("use_npu", False) use_mlu = global_config.get("use_mlu", False) + use_ascend = global_config.get("use_ascend", False) assert ( - use_gpu and use_xpu and use_npu and use_mlu - ) is not True, "gpu, xpu, npu and mlu can not be true in the same time in static mode!" + use_gpu and use_xpu and use_npu and use_mlu and use_ascend + ) is not True, "gpu, xpu, npu, mlu and ascend can not be true in the same time in static mode!" if use_gpu: device = paddle.set_device('gpu') @@ -104,6 +105,8 @@ def main(args): device = paddle.set_device('npu') elif use_mlu: device = paddle.set_device('mlu') + elif use_ascend: + device = paddle.set_device('ascend') else: device = paddle.set_device('cpu') -- GitLab