Skip to content

fix: gpu use p3/p2 per avail for region #2902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@
"me-south-1",
]

NO_P3_REGIONS = [
"af-south-1",
"ap-east-1",
"ap-southeast-1", # it has p3, but not enough
"ap-southeast-2", # it has p3, but not enough
"ca-central-1", # it has p3, but not enough
"eu-central-1", # it has p3, but not enough
"eu-north-1",
"eu-west-2", # it has p3, but not enough
"eu-west-3",
"eu-south-1",
"me-south-1",
"sa-east-1",
"us-west-1",
"ap-northeast-1", # it has p3, but not enough
"ap-south-1",
"ap-northeast-2", # it has p3, but not enough
]

NO_T2_REGIONS = ["eu-north-1", "ap-east-1", "me-south-1"]

FRAMEWORKS_FOR_GENERATED_VERSION_FIXTURES = (
Expand Down Expand Up @@ -361,9 +380,13 @@ def cpu_instance_type(sagemaker_session, request):
return "ml.m4.xlarge"


@pytest.fixture(scope="module")
def gpu_instance_type(request):
return "ml.p3.2xlarge"
@pytest.fixture(scope="session")
def gpu_instance_type(sagemaker_session, request):
region = sagemaker_session.boto_session.region_name
if region in NO_P3_REGIONS:
return "ml.p2.xlarge"
else:
return "ml.p3.2xlarge"


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -405,10 +428,16 @@ def pytest_generate_tests(metafunc):

params = [cpu_instance_type]
if not (
region in tests.integ.HOSTING_NO_P3_REGIONS
or region in tests.integ.TRAINING_NO_P3_REGIONS
):
params.append("ml.p3.2xlarge")
elif not (
region in tests.integ.HOSTING_NO_P2_REGIONS
or region in tests.integ.TRAINING_NO_P2_REGIONS
):
params.append("ml.p3.2xlarge")
params.append("ml.p2.xlarge")

metafunc.parametrize("instance_type", params, scope="session")

_generate_all_framework_version_fixtures(metafunc)
Expand Down
18 changes: 18 additions & 0 deletions tests/integ/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@
"sa-east-1",
"us-west-1",
]
TRAINING_NO_P3_REGIONS = [
"af-south-1",
"ap-east-1",
"ap-southeast-1", # it has p3, but not enough
"ap-southeast-2", # it has p3, but not enough
"ca-central-1", # it has p3, but not enough
"eu-central-1", # it has p3, but not enough
"eu-north-1",
"eu-west-2", # it has p3, but not enough
"eu-west-3",
"eu-south-1",
"me-south-1",
"sa-east-1",
"us-west-1",
"ap-northeast-1", # it has p3, but not enough
"ap-south-1",
"ap-northeast-2", # it has p3, but not enough
]

# EI is currently only supported in the following regions
# regions were derived from https://aws.amazon.com/machine-learning/elastic-inference/pricing/
Expand Down
7 changes: 5 additions & 2 deletions tests/integ/test_horovod.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,22 @@ def test_hvd_cpu(

@pytest.mark.release
@pytest.mark.skipif(
integ.test_region() in integ.TRAINING_NO_P2_REGIONS, reason="no ml.p2 instances in this region"
integ.test_region() in integ.TRAINING_NO_P2_REGIONS
and integ.test_region() in integ.TRAINING_NO_P3_REGIONS,
reason="no ml.p2 or ml.p3 instances in this region",
)
def test_hvd_gpu(
sagemaker_session,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
gpu_instance_type,
tmpdir,
):
_create_and_fit_estimator(
sagemaker_session,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
"ml.p3.2xlarge",
gpu_instance_type,
tmpdir,
)

Expand Down
4 changes: 3 additions & 1 deletion tests/integ/test_horovod_mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def test_hvd_cpu(

@pytest.mark.release
@pytest.mark.skipif(
integ.test_region() in integ.TRAINING_NO_P2_REGIONS, reason="no ml.p2 instances in this region"
integ.test_region() in integ.TRAINING_NO_P2_REGIONS
and integ.test_region() in integ.TRAINING_NO_P3_REGIONS,
reason="no ml.p2 or ml.p3 instances in this region",
)
def test_hvd_gpu(
mxnet_training_latest_version,
Expand Down
14 changes: 9 additions & 5 deletions tests/integ/test_huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@

@pytest.mark.release
@pytest.mark.skipif(
integ.test_region() in integ.TRAINING_NO_P2_REGIONS,
reason="no ml.p2 instances in this region",
integ.test_region() in integ.TRAINING_NO_P2_REGIONS
and integ.test_region() in integ.TRAINING_NO_P3_REGIONS,
reason="no ml.p2 or ml.p3 instances in this region",
)
def test_framework_processing_job_with_deps(
sagemaker_session,
Expand Down Expand Up @@ -63,8 +64,9 @@ def test_framework_processing_job_with_deps(

@pytest.mark.release
@pytest.mark.skipif(
integ.test_region() in integ.TRAINING_NO_P2_REGIONS,
reason="no ml.p2 instances in this region",
integ.test_region() in integ.TRAINING_NO_P2_REGIONS
and integ.test_region() in integ.TRAINING_NO_P3_REGIONS,
reason="no ml.p2 or ml.p3 instances in this region",
)
def test_huggingface_training(
sagemaker_session,
Expand Down Expand Up @@ -108,7 +110,9 @@ def test_huggingface_training(

@pytest.mark.release
@pytest.mark.skipif(
integ.test_region() in integ.TRAINING_NO_P2_REGIONS, reason="no ml.p2 instances in this region"
integ.test_region() in integ.TRAINING_NO_P2_REGIONS
and integ.test_region() in integ.TRAINING_NO_P3_REGIONS,
reason="no ml.p2 or ml.p3 instances in this region",
)
def test_huggingface_training_tf(
sagemaker_session,
Expand Down