Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Modify EI image repository and tag to match Python SDK. #12

Merged
merged 2 commits into from
Mar 7, 2019
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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ To build an image, run the `./scripts/build.sh` script:
```bash
./scripts/build.sh --version 1.11 --arch cpu
./scripts/build.sh --version 1.11 --arch gpu
./scripts/build.sh --version 1.11 --arch ei
./scripts/build.sh --version 1.11 --arch eia
```


Expand All @@ -68,7 +68,7 @@ in SageMaker, you need to publish it to an ECR repository in your account. The
```bash
./scripts/publish.sh --version 1.11 --arch cpu
./scripts/publish.sh --version 1.11 --arch gpu
./scripts/publish.sh --version 1.11 --arch ei
./scripts/publish.sh --version 1.11 --arch eia
```

Note: this will publish to ECR in your default region. Use the `--region` argument to
Expand All @@ -82,8 +82,8 @@ GPU images) will work for this, or you can use the provided `start.sh`
and `stop.sh` scripts:

```bash
./scripts/start.sh [--version x.xx] [--arch cpu|gpu|ei|...]
./scripts/stop.sh [--version x.xx] [--arch cpu|gpu|ei|...]
./scripts/start.sh [--version x.xx] [--arch cpu|gpu|eia|...]
./scripts/stop.sh [--version x.xx] [--arch cpu|gpu|eia|...]
```

When the container is running, you can send test requests to it using any HTTP client. Here's
Expand Down Expand Up @@ -118,11 +118,11 @@ To test against Elastic Inference with Accelerator, you will need an AWS account

For example:

pytest test/integrationsagemaker/test_elastic_inference.py --aws-id 0123456789012 \
--docker-base-name sagemaker-tensorflow-serving \
--instance_type ml.m4.xlarge \
--accelerator-type ml.eia1.large \
--tag 1.12.0-ei
pytest test/integration/sagemaker/test_elastic_inference.py --aws-id 0123456789012 \
--docker-base-name sagemaker-tensorflow-serving-eia \
--instance_type ml.m4.xlarge \
--accelerator-type ml.eia1.medium \
--tag 1.12.0-cpu

## Contributing

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ source scripts/shared.sh

parse_std_args "$@"

if [ $arch = 'ei' ]; then
if [ $arch = 'eia' ]; then
get_tfs_executable
fi

echo "pulling previous image for layer cache... "
$(aws ecr get-login --no-include-email --registry-id $aws_account) &>/dev/null || echo 'warning: ecr login failed'
docker pull $aws_account.dkr.ecr.$aws_region.amazonaws.com/sagemaker-tensorflow-serving:$full_version-$arch &>/dev/null || echo 'warning: pull failed'
docker pull $aws_account.dkr.ecr.$aws_region.amazonaws.com/$repository:$full_version-$device &>/dev/null || echo 'warning: pull failed'
docker logout https://$aws_account.dkr.ecr.$aws_region.amazonaws.com &>/dev/null

echo "building image... "
docker build \
--cache-from $aws_account.dkr.ecr.$aws_region.amazonaws.com/sagemaker-tensorflow-serving:$full_version-$arch \
--cache-from $aws_account.dkr.ecr.$aws_region.amazonaws.com/$repository:$full_version-$device \
--build-arg TFS_VERSION=$full_version \
--build-arg TFS_SHORT_VERSION=$short_version \
-f docker/Dockerfile.$arch \
-t sagemaker-tensorflow-serving:$full_version-$arch \
-t sagemaker-tensorflow-serving:$short_version-$arch container
-t $repository:$full_version-$device \
-t $repository:$short_version-$device container
8 changes: 4 additions & 4 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ source scripts/shared.sh
parse_std_args "$@"

$(aws ecr get-login --no-include-email --registry-id $aws_account)
docker tag sagemaker-tensorflow-serving:$full_version-$arch $aws_account.dkr.ecr.$aws_region.amazonaws.com/sagemaker-tensorflow-serving:$full_version-$arch
docker tag sagemaker-tensorflow-serving:$full_version-$arch $aws_account.dkr.ecr.$aws_region.amazonaws.com/sagemaker-tensorflow-serving:$short_version-$arch
docker push $aws_account.dkr.ecr.$aws_region.amazonaws.com/sagemaker-tensorflow-serving:$full_version-$arch
docker push $aws_account.dkr.ecr.$aws_region.amazonaws.com/sagemaker-tensorflow-serving:$short_version-$arch
docker tag $repository:$full_version-$device $aws_account.dkr.ecr.$aws_region.amazonaws.com/$repository:$full_version-$device
docker tag $repository:$full_version-$device $aws_account.dkr.ecr.$aws_region.amazonaws.com/$repository:$short_version-$device
docker push $aws_account.dkr.ecr.$aws_region.amazonaws.com/$repository:$full_version-$device
docker push $aws_account.dkr.ecr.$aws_region.amazonaws.com/$repository:$short_version-$device
docker logout https://$aws_account.dkr.ecr.$aws_region.amazonaws.com
16 changes: 14 additions & 2 deletions scripts/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

function error() {
>&2 echo $1
>&2 echo "usage: $0 [--version <major-version>] [--arch (cpu*|gpu|ei)] [--region <aws-region>]"
>&2 echo "usage: $0 [--version <major-version>] [--arch (cpu*|gpu|eia)] [--region <aws-region>]"
exit 1
}

Expand Down Expand Up @@ -39,10 +39,19 @@ function get_tfs_executable() {
rm ${zip_file} && rm -rf exec_dir
}

function get_device_type() {

Choose a reason for hiding this comment

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

I think it would be less confusing to explicitly show that providing EI results in cpu being selected here.

Copy link
Contributor

Choose a reason for hiding this comment

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

user has to provide eia/gpu/cpu arg to script so is this method even needed?

if [ $1 = 'eia' ]; then
echo 'cpu'
else
echo $1
fi
}

function parse_std_args() {
# defaults
arch='cpu'
version='1.12.0'
repository='sagemaker-tensorflow-serving'

aws_region=$(get_default_region)
aws_account=$(get_aws_account)
Expand Down Expand Up @@ -74,11 +83,14 @@ function parse_std_args() {
done

[[ -z "${version// }" ]] && error 'missing version'
[[ "$arch" =~ ^(cpu|gpu|ei)$ ]] || error "invalid arch: $arch"
[[ "$arch" =~ ^(cpu|gpu|eia)$ ]] || error "invalid arch: $arch"
[[ -z "${aws_region// }" ]] && error 'missing aws region'

[[ "$arch" = eia ]] && repository=$repository'-'$arch

full_version=$(get_full_version $version)
short_version=$(get_short_version $version)
device=$(get_device_type $arch)

true
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ $docker_command run \
-e "SAGEMAKER_TFS_NGINX_LOGLEVEL=error" \
-e "SAGEMAKER_BIND_TO_PORT=8080" \
-e "SAGEMAKER_SAFE_PORT_RANGE=9000-9999" \
sagemaker-tensorflow-serving:$full_version-$arch serve > log.txt 2>&1 &
$repository:$full_version-$device serve > log.txt 2>&1 &
2 changes: 1 addition & 1 deletion scripts/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ source scripts/shared.sh

parse_std_args "$@"

docker kill $(docker ps -q --filter ancestor=sagemaker-tensorflow-serving:$full_version-$arch)
docker kill $(docker ps -q --filter ancestor=$repository:$full_version-$device)