Skip to content

Commit f1fa18e

Browse files
author
wanyixia
committed
change: upgrade TF Serving version to TF2.3.0
1 parent 6ae56d3 commit f1fa18e

File tree

5 files changed

+85
-11
lines changed

5 files changed

+85
-11
lines changed

src/sagemaker/image_uri_config/tensorflow.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"1.13": "1.13.0",
1111
"1.14": "1.14.0",
1212
"1.15": "1.15.0",
13-
"2.0": "2.0.0"
13+
"2.0": "2.0.0",
14+
"2.3": "2.3.0"
1415
},
1516
"versions": {
1617
"1.10.0": {
@@ -190,6 +191,35 @@
190191
},
191192
"repository": "tensorflow-inference-eia"
192193
},
194+
"2.0.0": {
195+
"registries": {
196+
"af-south-1": "626614931356",
197+
"ap-east-1": "871362719292",
198+
"ap-northeast-1": "763104351884",
199+
"ap-northeast-2": "763104351884",
200+
"ap-south-1": "763104351884",
201+
"ap-southeast-1": "763104351884",
202+
"ap-southeast-2": "763104351884",
203+
"ca-central-1": "763104351884",
204+
"cn-north-1": "727897471807",
205+
"cn-northwest-1": "727897471807",
206+
"eu-central-1": "763104351884",
207+
"eu-north-1": "763104351884",
208+
"eu-south-1": "692866216735",
209+
"eu-west-1": "763104351884",
210+
"eu-west-2": "763104351884",
211+
"eu-west-3": "763104351884",
212+
"me-south-1": "217643126080",
213+
"sa-east-1": "763104351884",
214+
"us-east-1": "763104351884",
215+
"us-east-2": "763104351884",
216+
"us-gov-west-1": "442386744353",
217+
"us-iso-east-1": "886529160074",
218+
"us-west-1": "763104351884",
219+
"us-west-2": "763104351884"
220+
},
221+
"repository": "tensorflow-inference-eia"
222+
},
193223
"2.0.0": {
194224
"registries": {
195225
"af-south-1": "626614931356",

src/sagemaker/tensorflow/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class TensorFlowModel(sagemaker.model.FrameworkModel):
118118
logging.ERROR: "error",
119119
logging.CRITICAL: "crit",
120120
}
121-
LATEST_EIA_VERSION = [2, 0]
121+
LATEST_EIA_VERSION = [2, 3]
122122

123123
def __init__(
124124
self,

tests/data/cuteCat.jpg

6.43 KB
Loading

tests/integ/test_tfs.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,42 @@ def tfs_predictor_with_accelerator(
138138
yield predictor
139139

140140

141+
@pytest.fixture(scope="module")
142+
def tfs_trt_predictor_with_accelerator(
143+
sagemaker_session, tensorflow_eia_latest_version, cpu_instance_type
144+
):
145+
endpoint_name = sagemaker.utils.unique_name_from_base("sagemaker-tensorflow-serving")
146+
model_data = sagemaker_session.upload_data(
147+
path=os.path.join(tests.integ.DATA_DIR, "tensorflow-serving-test-model.tar.gz"),
148+
key_prefix="tensorflow-serving/compiledmodels",
149+
)
150+
bucket = sagemaker_session.default_bucket()
151+
with tests.integ.timeout.timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
152+
model = TensorFlowModel(
153+
model_data=model_data,
154+
role="SageMakerRole",
155+
framework_version=tensorflow_eia_latest_version,
156+
sagemaker_session=sagemaker_session,
157+
name=endpoint_name,
158+
)
159+
data_shape = {"input": [1, 224, 224, 3]}
160+
tfs_eia_compilation_job_name = "tfs_eia_compilation_job_name"
161+
compiled_model_path = "s3://{}/{}/output".format(bucket, tfs_eia_compilation_job_name)
162+
compiled_model = model.compile(
163+
target_instance_family='ml_eia2',
164+
input_shape=data_shape,
165+
output_path=compiled_model_path,
166+
role="SageMakerRole",
167+
job_name=tfs_eia_compilation_job_name,
168+
framework='tensorflow',
169+
framework_version='2.3'
170+
)
171+
predictor = compiled_model.deploy(
172+
1, cpu_instance_type, endpoint_name=endpoint_name, accelerator_type="ml.eia2.large"
173+
)
174+
yield predictor
175+
176+
141177
@pytest.mark.release
142178
def test_predict(tfs_predictor):
143179
input_data = {"instances": [1.0, 2.0, 5.0]}
@@ -160,6 +196,23 @@ def test_predict_with_accelerator(tfs_predictor_with_accelerator):
160196
assert expected_result == result
161197

162198

199+
@pytest.mark.skipif(
200+
tests.integ.test_region() not in tests.integ.EI_SUPPORTED_REGIONS,
201+
reason="EI is not supported in region {}".format(tests.integ.test_region()),
202+
)
203+
@pytest.mark.release
204+
def test_trt_predict_with_accelerator(tfs_predictor_with_accelerator):
205+
import numpy as np
206+
import matplotlib.image as mpimg
207+
path = os.path.join(tests.integ.DATA_DIR, "cuteCat.jpg")
208+
img = mpimg.imread(path)
209+
img = np.resize(img, (299, 299, 3))
210+
img = np.expand_dims(img, axis=0)
211+
input_data = {"inputs": img}
212+
result = tfs_trt_predictor_with_accelerator.predict(input_data)
213+
print("trt predictor result is: " + result)
214+
215+
163216
@pytest.mark.local_mode
164217
def test_predict_with_entry_point(tfs_predictor_with_model_and_entry_point_same_tar):
165218
input_data = {"instances": [1.0, 2.0, 5.0]}

tests/unit/sagemaker/tensorflow/test_tfs.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,6 @@ def test_tfs_model_image_accelerator_not_supported(sagemaker_session):
142142

143143
model.deploy(instance_type="ml.c4.xlarge", initial_instance_count=1)
144144

145-
with pytest.raises(AttributeError) as e:
146-
model.deploy(
147-
instance_type="ml.c4.xlarge",
148-
accelerator_type="ml.eia1.medium",
149-
initial_instance_count=1,
150-
)
151-
152-
assert str(e.value) == "The TensorFlow version 2.1 doesn't support EIA."
153-
154145

155146
def test_tfs_model_with_log_level(sagemaker_session, tensorflow_inference_version):
156147
model = TensorFlowModel(

0 commit comments

Comments
 (0)