|
| 1 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"). You |
| 4 | +# may not use this file except in compliance with the License. A copy of |
| 5 | +# the License is located at |
| 6 | +# |
| 7 | +# http://aws.amazon.com/apache2.0/ |
| 8 | +# |
| 9 | +# or in the "license" file accompanying this file. This file is |
| 10 | +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF |
| 11 | +# ANY KIND, either express or implied. See the License for the specific |
| 12 | +# language governing permissions and limitations under the License. |
| 13 | +from __future__ import absolute_import |
| 14 | + |
| 15 | +from sagemaker import image_uris |
| 16 | +from tests.unit.sagemaker.image_uris import expected_uris |
| 17 | + |
| 18 | +ACCOUNTS = { |
| 19 | + "af-south-1": "626614931356", |
| 20 | + "ap-east-1": "871362719292", |
| 21 | + "ap-northeast-1": "763104351884", |
| 22 | + "ap-northeast-2": "763104351884", |
| 23 | + "ap-northeast-3": "364406365360", |
| 24 | + "ap-south-1": "763104351884", |
| 25 | + "ap-southeast-1": "763104351884", |
| 26 | + "ap-southeast-2": "763104351884", |
| 27 | + "ca-central-1": "763104351884", |
| 28 | + "cn-north-1": "727897471807", |
| 29 | + "cn-northwest-1": "727897471807", |
| 30 | + "eu-central-1": "763104351884", |
| 31 | + "eu-north-1": "763104351884", |
| 32 | + "eu-west-1": "763104351884", |
| 33 | + "eu-west-2": "763104351884", |
| 34 | + "eu-west-3": "763104351884", |
| 35 | + "eu-south-1": "692866216735", |
| 36 | + "me-south-1": "217643126080", |
| 37 | + "sa-east-1": "763104351884", |
| 38 | + "us-east-1": "763104351884", |
| 39 | + "us-east-2": "763104351884", |
| 40 | + "us-gov-west-1": "442386744353", |
| 41 | + "us-iso-east-1": "886529160074", |
| 42 | + "us-west-1": "763104351884", |
| 43 | + "us-west-2": "763104351884", |
| 44 | +} |
| 45 | + |
| 46 | +TRAINIUM_REGIONS = ACCOUNTS.keys() |
| 47 | + |
| 48 | + |
| 49 | +def _expected_trainium_framework_uri( |
| 50 | + framework, version, region="us-west-2", inference_tool="neuron" |
| 51 | +): |
| 52 | + return expected_uris.neuron_framework_uri( |
| 53 | + "{}-neuron".format(framework), |
| 54 | + fw_version=version, |
| 55 | + py_version="py38", |
| 56 | + account=ACCOUNTS[region], |
| 57 | + region=region, |
| 58 | + inference_tool=inference_tool, |
| 59 | + ) |
| 60 | + |
| 61 | + |
| 62 | +def _test_trainium_framework_uris(framework, version): |
| 63 | + for region in TRAINIUM_REGIONS: |
| 64 | + uri = image_uris.retrieve( |
| 65 | + framework, region, instance_type="ml.trn1.xlarge", version=version |
| 66 | + ) |
| 67 | + expected = _expected_trainium_framework_uri( |
| 68 | + "{}-training".format(framework), version, region=region, inference_tool="neuron" |
| 69 | + ) |
| 70 | + assert expected == uri |
| 71 | + |
| 72 | + |
| 73 | +def test_trainium_pytorch(pytorch_neuron_version): |
| 74 | + _test_trainium_framework_uris("pytorch", pytorch_neuron_version) |
0 commit comments