Skip to content

change: add mxnet 1.7.0 eia configuration #2173

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 9 commits into from
Feb 26, 2021
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
33 changes: 32 additions & 1 deletion src/sagemaker/image_uri_config/mxnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@
"version_aliases": {
"1.3": "1.3.0",
"1.4": "1.4.1",
"1.5": "1.5.1"
"1.5": "1.5.1",
"1.7": "1.7.0"
},
"versions": {
"1.3.0": {
Expand Down Expand Up @@ -816,6 +817,36 @@
},
"repository": "mxnet-inference-eia",
"py_versions": ["py2", "py3"]
},
"1.7.0": {
"registries": {
"af-south-1": "626614931356",
"ap-east-1": "871362719292",
"ap-northeast-1": "763104351884",
"ap-northeast-2": "763104351884",
"ap-south-1": "763104351884",
"ap-southeast-1": "763104351884",
"ap-southeast-2": "763104351884",
"ca-central-1": "763104351884",
"cn-north-1": "727897471807",
"cn-northwest-1": "727897471807",
"eu-central-1": "763104351884",
"eu-north-1": "763104351884",
"eu-west-1": "763104351884",
"eu-west-2": "763104351884",
"eu-west-3": "763104351884",
"eu-south-1": "692866216735",
"me-south-1": "217643126080",
"sa-east-1": "763104351884",
"us-east-1": "763104351884",
"us-east-2": "763104351884",
"us-gov-west-1": "442386744353",
"us-iso-east-1": "886529160074",
"us-west-1": "763104351884",
"us-west-2": "763104351884"
},
"repository": "mxnet-inference-eia",
"py_versions": ["py3"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this might need to be py36 as per aws/deep-learning-containers@cab6c4e.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. Will update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For MXNet 1.7.0 training image, though the image tag is py36, in this file it still specifies the py_version as py3. We should keep training and inference images the same, otherwise when deploying the endpoint, it errors out because the py_version doesn't match. So I'll leave it as py3 to be consistent with the training image.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon checking

docker pull 763104351884.dkr.ecr.us-west-2.amazonaws.com/mxnet-inference-eia:1.7.0-cpu-py36
docker pull 763104351884.dkr.ecr.us-west-2.amazonaws.com/mxnet-inference-eia:1.7.0-cpu-py3

Are both valid, so I'm okay with having py3. We add py36 in a separate PR if desired.

}
}
}
Expand Down
12 changes: 10 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,16 @@ def mxnet_training_py_version(mxnet_training_version, request):


@pytest.fixture(scope="module", params=["py2", "py3"])
def mxnet_eia_py_version(request):
return request.param
def mxnet_eia_py_version(mxnet_eia_version, request):
if Version(mxnet_eia_version) < Version("1.7.0"):
return request.param
else:
return "py3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this might need to be py36 as per aws/deep-learning-containers@cab6c4e.



@pytest.fixture(scope="module")
def mxnet_eia_latest_py_version():
return "py3"


@pytest.fixture(scope="module", params=["py2", "py3"])
Expand Down
58 changes: 58 additions & 0 deletions tests/data/mxnet_mnist/mnist_ei.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file 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.
from __future__ import absolute_import

import argparse
import gzip
import json
import logging
import os
import struct

import mxnet as mx
import numpy as np


def model_fn(model_dir):
import eimx

def read_data_shapes(path, preferred_batch_size=1):
with open(path, "r") as f:
signatures = json.load(f)

data_names = []
data_shapes = []

for s in signatures:
name = s["name"]
data_names.append(name)

shape = s["shape"]

if preferred_batch_size:
shape[0] = preferred_batch_size

data_shapes.append((name, shape))

return data_names, data_shapes

shapes_file = os.path.join(model_dir, "model-shapes.json")
data_names, data_shapes = read_data_shapes(shapes_file)

ctx = mx.cpu()
sym, args, aux = mx.model.load_checkpoint(os.path.join(model_dir, "model"), 0)
sym = sym.optimize_for("EIA")

mod = mx.mod.Module(symbol=sym, context=ctx, data_names=data_names, label_names=None)
mod.bind(for_training=False, data_shapes=data_shapes)
mod.set_params(args, aux, allow_missing=True)

return mod
6 changes: 3 additions & 3 deletions tests/integ/test_mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def test_deploy_model_with_accelerator(
mxnet_training_job,
sagemaker_session,
mxnet_eia_latest_version,
mxnet_eia_py_version,
mxnet_eia_latest_py_version,
cpu_instance_type,
):
endpoint_name = "test-mxnet-deploy-model-ei-{}".format(sagemaker_timestamp())
Expand All @@ -323,13 +323,13 @@ def test_deploy_model_with_accelerator(
TrainingJobName=mxnet_training_job
)
model_data = desc["ModelArtifacts"]["S3ModelArtifacts"]
script_path = os.path.join(DATA_DIR, "mxnet_mnist", "mnist.py")
script_path = os.path.join(DATA_DIR, "mxnet_mnist", "mnist_ei.py")
model = MXNetModel(
model_data,
"SageMakerRole",
entry_point=script_path,
framework_version=mxnet_eia_latest_version,
py_version=mxnet_eia_py_version,
py_version=mxnet_eia_latest_py_version,
sagemaker_session=sagemaker_session,
)
predictor = model.deploy(
Expand Down