forked from mindspore-Ecosystem/mindspore
!28580 add pynative 8p testcase
Merge pull request !28580 from caifubi/master-pynative-testcase
This commit is contained in:
commit
3f899434b9
|
@ -16,7 +16,6 @@
|
|||
import time
|
||||
import random
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import mindspore.common.dtype as mstype
|
||||
import mindspore.dataset as ds
|
||||
|
@ -33,6 +32,8 @@ from mindspore.ops import operations as P
|
|||
from mindspore.ops import composite as CP
|
||||
from mindspore.nn.optim.momentum import Momentum
|
||||
from mindspore.nn.wrap.cell_wrapper import WithLossCell
|
||||
from mindspore.context import ParallelMode
|
||||
from mindspore.communication.management import init
|
||||
|
||||
random.seed(1)
|
||||
np.random.seed(1)
|
||||
|
@ -377,11 +378,11 @@ class GradWrap(Cell):
|
|||
return grad_by_list(self.network, weights)(x, label)
|
||||
|
||||
|
||||
@pytest.mark.level0
|
||||
@pytest.mark.platform_x86_gpu_training
|
||||
@pytest.mark.env_onecard
|
||||
def test_pynative_resnet50():
|
||||
context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU")
|
||||
context.reset_auto_parallel_context()
|
||||
context.set_auto_parallel_context(parallel_mode=ParallelMode.DATA_PARALLEL, gradients_mean=False, device_num=8)
|
||||
init()
|
||||
|
||||
batch_size = 32
|
||||
num_classes = 10
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# Copyright 2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# 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.
|
||||
# ============================================================================
|
||||
import os
|
||||
import pytest
|
||||
|
||||
@pytest.mark.level0
|
||||
@pytest.mark.platform_x86_gpu_training
|
||||
@pytest.mark.env_single
|
||||
def test_pynative_resnet50_gpu_8p_performance():
|
||||
"""
|
||||
Feature: PyNative ResNet50 8P
|
||||
Description: test PyNative ResNet50 8p performance
|
||||
Expectation: success, return_code==0
|
||||
"""
|
||||
return_code = os.system("mpirun -n 8 pytest -s test_pynative_resnet50_gpu.py")
|
||||
assert return_code == 0
|
Loading…
Reference in New Issue