已合并
Skip test_aclrtSetDevice on 910A because it is slow #22797
yuhaiyan8创建于 2025年7月8日
Skip test_aclrtSetDevice on 910A because it is slow #22797
已合并
从refs/pull/22797/head合入到v2.7.1
共 2 个文件变更+7-3
| @@ -11,7 +11,7 @@ def _worker(i: int) -> None: | |||
| 11 | def set_device(): | 11 | def set_device(): |
| 12 | torch_npu.npu.set_device(0) | 12 | torch_npu.npu.set_device(0) |
| 13 | multiprocessing.set_start_method("spawn", force=True) | 13 | multiprocessing.set_start_method("spawn", force=True) |
| 14 | - jobs = [multiprocessing.Process(target=_worker, args=(i,)) for i in range(70)] | 14 | + jobs = [multiprocessing.Process(target=_worker, args=(i,)) for i in range(100)] |
| 15 | 15 | ||
| 16 | for p in jobs: | 16 | for p in jobs: |
| 17 | p.start() | 17 | p.start() |
| @@ -19,5 +19,5 @@ def set_device(): | |||
| 19 | for p in jobs: | 19 | for p in jobs: |
| 20 | p.join() | 20 | p.join() |
| 21 | 21 | ||
| 22 | - | 22 | +if __name__ == "__main__": |
| 23 | -set_device() | 23 | + set_device() |
| @@ -6,6 +6,9 @@ from torch.testing._internal.common_utils import TestCase, run_tests | |||
| 6 | from torch.utils.checkpoint import checkpoint | 6 | from torch.utils.checkpoint import checkpoint |
| 7 | import torch.distributed as dist | 7 | import torch.distributed as dist |
| 8 | import torch.nn as nn | 8 | import torch.nn as nn |
| 9 | + | ||
| 10 | +from torch_npu.testing.common_utils import SupportedDevices | ||
| 11 | + | ||
| 9 | os.environ["ASCEND_LAUNCH_BLOCKING"] = '0' | 12 | os.environ["ASCEND_LAUNCH_BLOCKING"] = '0' |
| 10 | import torch_npu | 13 | import torch_npu |
| 11 | 14 | ||
| @@ -156,6 +159,7 @@ class TestMode(TestCase): | |||
| 156 | with self.assertRaisesRegex(RuntimeError, "Invalid device argument"): | 159 | with self.assertRaisesRegex(RuntimeError, "Invalid device argument"): |
| 157 | torch.npu.reset_max_memory_allocated(device="npu:8") | 160 | torch.npu.reset_max_memory_allocated(device="npu:8") |
| 158 | 161 | ||
| 162 | + | ||
| 159 | def test_aclrtSetDevice(self): | 163 | def test_aclrtSetDevice(self): |
| 160 | path = os.path.join(os.path.dirname(__file__), '_fault_mode_cases/error_set_device.py') | 164 | path = os.path.join(os.path.dirname(__file__), '_fault_mode_cases/error_set_device.py') |
| 161 | process = subprocess.Popen(["python", f"{path}"], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) | 165 | process = subprocess.Popen(["python", f"{path}"], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) |