Skip to content

Commit bc16b05

Browse files
authored
update set_context API for ms2.5 version (#815)
1 parent c879001 commit bc16b05

File tree

9 files changed

+17
-19
lines changed

9 files changed

+17
-19
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
matrix:
2222
os: [ubuntu-latest]
23-
python-version: ["3.8"] #["3.7", "3.8", "3.9"] TBA
23+
python-version: ["3.9"] #["3.7", "3.8", "3.9"] TBA
2424
runs-on: ${{ matrix.os }}
2525

2626
steps:
@@ -35,7 +35,7 @@ jobs:
3535
pip install -r requirements/dev.txt
3636
# MindSpore must be installed following the instruction from official web, but not from pypi.
3737
# That's why we exclude mindspore from requirements.txt. Does this work?
38-
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.3.0/MindSpore/unified/x86_64/mindspore-2.3.0-cp38-cp38-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
38+
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.5.0/MindSpore/unified/x86_64/mindspore-2.5.0-cp39-cp39-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
3939
- name: Lint with pre-commit
4040
uses: pre-commit/[email protected]
4141
- name: Check_Cpplint

deploy/eval_utils/eval_rec.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def read_gt_content(filename):
6868

6969

7070
if __name__ == "__main__":
71-
ms.set_context(device_target="CPU")
71+
ms.set_device("CPU")
7272
parser = argparse.ArgumentParser()
7373
parser.add_argument("--gt_path", required=True, type=str)
7474
parser.add_argument("--pred_path", required=True, type=str)

deploy/py_infer/src/data_process/postprocess/builder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, tasks, **kwargs):
2626
# if check device failed, set device_target="CPU"
2727
if get_device_status() == 1:
2828
# FIXME: set_context may be invalid sometimes, it's best to patch to XXXPostprocess.__init__
29-
ms.set_context(device_target="CPU")
29+
ms.set_device("CPU")
3030

3131
def __call__(self, *args, **kwargs):
3232
return self._ops_func(*args, **kwargs)

docs/en/tutorials/frequently_asked_questions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ For example, the following combination of packages is suitable when the platform
116116
- `Load dynamic library: libmindspore_ascend.so.2 failed. liboptiling.so: cannot open shared object file: No such file or directory`
117117
118118
```bash
119-
python -c "import mindspore;mindspore.set_context(device_target='Ascend');mindspore.run_check()"
119+
python -c "import mindspore;mindspore.set_device('Ascend');mindspore.run_check()"
120120
[WARNING] ME(60105:13981374421 1776, MainProcess):2023-10-25-08: 14:33.640.411 [mindspore/run_check/_check_version.py:348] Using custom Ascend AI software package (Ascend Data Center Solution) path, package version checking is skipped. Please make sure Ascend AI software package (Ascend Data Center Solution) version is supported. For details, refer to the installation guidelines https://www.mindspore.cn/install
121121
Traceback (most recent call last):
122122
File "<string>", line 1, in module>
@@ -412,7 +412,7 @@ Remove the `lanms` item from `requirements.txt`, and run `pip install -r require
412412
[WARNING] ME(44720:140507814819648,MainProcess):2023-11-01-03:01:38.884.384 [mindspore/run_check/_check_version.py:348] Using custom Ascend AI software package (Ascend Data Center Solution) path, package version checking is skipped. Please make sure Ascend AI software package (Ascend Data Center Solution) version is supported. For details, refer to the installation guidelines https://www.mindspore.cn/install
413413
[WARNING] ME(44720:140507814819648,MainProcess):2023-11-01-03:01:38.884.675 [mindspore/run_check/_check_version.py:466] Can not find driver so(need by mindspore-ascend). Please check whether the Environment Variable LD_LIBRARY_PATH is set. For details, refer to the installation guidelines: https://www.mindspore.cn/install
414414
>>> import mindspore.ops as ops
415-
>>> ms.set_context(device_target="Ascend")
415+
>>> ms.set_device("Ascend")
416416
>>> ms.run_check()
417417
MindSpore version: 2.2.0.20231025
418418
The result of multiplication calculation is correct, MindSpore has been installed on platform [Ascend] successfully!

docs/zh/tutorials/frequently_asked_questions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
- `Load dynamic library: libmindspore_ascend.so.2 failed. liboptiling.so: cannot open shared object file: No such file or directory`
119119
120120
```bash
121-
python -c "import mindspore;mindspore.set_context(device_target='Ascend');mindspore.run_check()"
121+
python -c "import mindspore;mindspore.set_device('Ascend');mindspore.run_check()"
122122
[WARNING] ME(60105:13981374421 1776, MainProcess):2023-10-25-08: 14:33.640.411 [mindspore/run_check/_check_version.py:348] Using custom Ascend AI software package (Ascend Data Center Solution) path, package version checking is skipped. Please make sure Ascend AI software package (Ascend Data Center Solution) version is supported. For details, refer to the installation guidelines https://www.mindspore.cn/install
123123
Traceback (most recent call last):
124124
File "<string>", line 1, in module>
@@ -418,7 +418,7 @@ ERROR: Could not build wheels for lanms-neo, which is required to install pyproj
418418
[WARNING] ME(44720:140507814819648,MainProcess):2023-11-01-03:01:38.884.384 [mindspore/run_check/_check_version.py:348] Using custom Ascend AI software package (Ascend Data Center Solution) path, package version checking is skipped. Please make sure Ascend AI software package (Ascend Data Center Solution) version is supported. For details, refer to the installation guidelines https://www.mindspore.cn/install
419419
[WARNING] ME(44720:140507814819648,MainProcess):2023-11-01-03:01:38.884.675 [mindspore/run_check/_check_version.py:466] Can not find driver so(need by mindspore-ascend). Please check whether the Environment Variable LD_LIBRARY_PATH is set. For details, refer to the installation guidelines: https://www.mindspore.cn/install
420420
>>> import mindspore.ops as ops
421-
>>> ms.set_context(device_target="Ascend")
421+
>>> ms.set_device("Ascend")
422422
>>> ms.run_check()
423423
MindSpore version: 2.2.0.20231025
424424
The result of multiplication calculation is correct, MindSpore has been installed on platform [Ascend] successfully!

mindocr/models/backbones/yolov8_backbone.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def yolov8_backbone(
118118

119119

120120
def test_yolo_backbone():
121-
ms.set_context(mode=ms.PYNATIVE_MODE, device_target='Ascend', device_id=3)
121+
ms.set_context(mode=ms.PYNATIVE_MODE)
122+
ms.set_device("Ascend", 3)
122123
ms.set_seed(0)
123124

124125
network = YOLOv8Backbone()

mindocr/models/heads/yolov8_head.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ def yolov8_head(nc=5, reg_max=16, stride=None, in_channels=None) -> YOLOv8Head:
124124

125125

126126
def test_yolov8_head():
127-
ms.set_context(mode=ms.PYNATIVE_MODE, device_target='Ascend', device_id=3)
127+
ms.set_context(mode=ms.PYNATIVE_MODE)
128+
ms.set_device("Ascend", 3)
128129
ms.set_seed(0)
129130

130131
network = yolov8_head()

tools/infer/text/predict_llm.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,13 @@ def __init__(self, args):
4545
config = LLMConfig(config_path)
4646
ms.set_context(
4747
mode=ms.GRAPH_MODE,
48-
device_target="Ascend",
49-
enable_graph_kernel=False,
50-
graph_kernel_flags="--disable_expand_ops=Softmax,Dropout --enable_parallel_fusion=true "
51-
"--reduce_fuse_depth=8 --enable_auto_tensor_inplace=true",
52-
ascend_config={"precision_mode": "must_keep_origin_dtype"},
53-
max_call_depth=10000,
54-
max_device_memory="58GB",
5548
save_graphs=False,
5649
save_graphs_path="./graph",
57-
device_id=os.environ.get("DEVICE_ID", 0),
5850
)
51+
ms.set_recursion_limit(10000)
52+
ms.set_device("Ascend", os.environ.get("DEVICE_ID", 0))
53+
ms.runtime.set_memory(max_size="58GB")
54+
ms.device_context.ascend.op_precision.precision_mode("must_keep_origin_dtype")
5955
self.tokenizer = QwenTokenizer(**config.processor.tokenizer)
6056
self.model = VaryQwenForCausalLM.from_pretrained(config_path)
6157

tools/train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def main(cfg):
4444
ms.runtime.set_cpu_affinity(True)
4545
ms.set_context(mode=cfg.system.mode)
4646
if cfg.train.max_call_depth:
47-
ms.set_context(max_call_depth=cfg.train.max_call_depth)
47+
ms.set_recursion_limit(cfg.train.max_call_depth)
4848
if cfg.system.mode == 0:
4949
ms.set_context(jit_config={"jit_level": "O2"})
5050
if cfg.system.distribute:

0 commit comments

Comments
 (0)