Skip to content

Commit d195aab

Browse files
arjkeshnadiaya
authored andcommitted
change: release 1.6.0 Dockerfiles (#82)
1 parent e7fa17b commit d195aab

17 files changed

+769
-43
lines changed

buildspec-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ version: 0.2
22

33
env:
44
variables:
5-
FRAMEWORK_FULL_VERSION: '1.4.1'
6-
FRAMEWORK_SHORT_VERSION: '1.4'
5+
FRAMEWORK_FULL_VERSION: '1.6.0'
6+
FRAMEWORK_SHORT_VERSION: '1.6'
77
AWS_DEFAULT_REGION: 'us-west-2'
88
ECR_REPO: 'sagemaker-mxnet-serving'
99
GITHUB_REPO: 'sagemaker-mxnet-serving-container'

buildspec.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ version: 0.2
22

33
env:
44
variables:
5-
FRAMEWORK_FULL_VERSION: '1.4.1'
5+
FRAMEWORK_FULL_VERSION: '1.6.0'
6+
EI_FRAMEWORK_VERSION: '1.4.1'
67
AWS_DEFAULT_REGION: 'us-west-2'
78
ECR_REPO: 'sagemaker-test'
89
GITHUB_REPO: 'sagemaker-mxnet-serving-container'
@@ -31,14 +32,18 @@ phases:
3132
- mv dist/sagemaker_mxnet_serving_container-*.tar.gz dist/sagemaker_mxnet_serving_container.tar.gz
3233
- cp dist/sagemaker_mxnet_serving_container.tar.gz docker/$FRAMEWORK_FULL_VERSION/py3/sagemaker_mxnet_serving_container.tar.gz
3334
- cp dist/sagemaker_mxnet_serving_container.tar.gz docker/$FRAMEWORK_FULL_VERSION/py2/sagemaker_mxnet_serving_container.tar.gz
35+
- cp dist/sagemaker_mxnet_serving_container.tar.gz docker/$EI_FRAMEWORK_VERSION/py3/sagemaker_mxnet_serving_container.tar.gz
36+
- cp dist/sagemaker_mxnet_serving_container.tar.gz docker/$EI_FRAMEWORK_VERSION/py2/sagemaker_mxnet_serving_container.tar.gz
37+
- cp src/sagemaker_mxnet_serving_container/deep_learning_container.py docker/$FRAMEWORK_FULL_VERSION/py3/deep_learning_container.py
38+
- cp src/sagemaker_mxnet_serving_container/deep_learning_container.py docker/$FRAMEWORK_FULL_VERSION/py2/deep_learning_container.py
3439

3540
- CPU_PY2_TAG=$FRAMEWORK_FULL_VERSION-cpu-py2
3641
- CPU_PY3_TAG=$FRAMEWORK_FULL_VERSION-cpu-py3
3742
- GPU_PY2_TAG=$FRAMEWORK_FULL_VERSION-gpu-py2
3843
- GPU_PY3_TAG=$FRAMEWORK_FULL_VERSION-gpu-py3
3944

4045
# build images
41-
- python3 scripts/build_all.py --version $FRAMEWORK_FULL_VERSION --account $ACCOUNT --repo $ECR_REPO
46+
- python3 scripts/build_all.py --version $FRAMEWORK_FULL_VERSION --eia-version $EI_FRAMEWORK_VERSION --account $ACCOUNT --repo $ECR_REPO
4247

4348
# run cpu local integration tests
4449
- |
@@ -49,7 +54,7 @@ phases:
4954
fi
5055
5156
# push docker images to ECR
52-
- python3 scripts/publish_all.py --version $FRAMEWORK_FULL_VERSION --account $ACCOUNT --repo $ECR_REPO
57+
- python3 scripts/publish_all.py --version $FRAMEWORK_FULL_VERSION --eia-version $EI_FRAMEWORK_VERSION --account $ACCOUNT --repo $ECR_REPO
5358

5459
# launch remote gpu instance
5560
- create-key-pair
@@ -77,7 +82,7 @@ phases:
7782
# run eia tests
7883
- |
7984
if has-matching-changes "test/" "tests/" "src/*.py" "docker/*" "buildspec.yml"; then
80-
IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker/test_elastic_inference.py -n 2 --py-version 2,3 --processor cpu --accelerator-type $EI_ACCELERATOR_TYPE --region $AWS_DEFAULT_REGION --docker-base-name "$ECR_REPO-eia" --aws-id $ACCOUNT --framework-version $FRAMEWORK_FULL_VERSION --reruns 3
85+
IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker/test_elastic_inference.py -n 2 --py-version 2,3 --processor cpu --accelerator-type $EI_ACCELERATOR_TYPE --region $AWS_DEFAULT_REGION --docker-base-name "$ECR_REPO-eia" --aws-id $ACCOUNT --framework-version $EI_FRAMEWORK_VERSION
8186
else
8287
echo "skipping sagemaker eia tests"
8388
fi

docker/1.4.1/py2/Dockerfile.eia

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ RUN pip install --no-cache-dir \
4949
mxnet-model-server==$MMS_VERSION \
5050
keras-mxnet==2.2.4.1 \
5151
onnx==1.4.1 \
52+
sagemaker-inference==1.1.0 \
5253
/sagemaker_mxnet_serving_container.tar.gz \
5354
&& rm /sagemaker_mxnet_serving_container.tar.gz
5455

docker/1.4.1/py3/Dockerfile.eia

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ RUN pip install --no-cache-dir \
7070
mxnet-model-server==$MMS_VERSION \
7171
keras-mxnet==2.2.4.1 \
7272
onnx==1.4.1 \
73+
sagemaker-inference==1.1.0 \
7374
/sagemaker_mxnet_serving_container.tar.gz \
7475
&& rm /sagemaker_mxnet_serving_container.tar.gz
7576

docker/1.6.0/py2/Dockerfile.cpu

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
FROM ubuntu:16.04
2+
3+
LABEL maintainer="Amazon AI"
4+
5+
# Specify accept-bind-to-port LABEL for inference pipelines to use SAGEMAKER_BIND_TO_PORT
6+
# https://docs.aws.amazon.com/sagemaker/latest/dg/inference-pipeline-real-time.html
7+
LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true
8+
# Specify multi-models LABEL to indicate container is capable of loading and serving multiple models concurrently
9+
# https://docs.aws.amazon.com/sagemaker/latest/dg/build-multi-model-build-container.html
10+
LABEL com.amazonaws.sagemaker.capabilities.multi-models=true
11+
12+
ARG MMS_VERSION=1.0.8
13+
ARG MX_URL=https://aws-mxnet-pypi.s3-us-west-2.amazonaws.com/1.6.0/aws_mxnet_mkl-1.6.0rc0-py2.py3-none-manylinux1_x86_64.whl
14+
ARG PYTHON=python
15+
ARG PYTHON_PIP=python-pip
16+
ARG PIP=pip
17+
18+
ENV PYTHONDONTWRITEBYTECODE=1 \
19+
PYTHONUNBUFFERED=1 \
20+
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" \
21+
PYTHONIOENCODING=UTF-8 \
22+
LANG=C.UTF-8 \
23+
LC_ALL=C.UTF-8 \
24+
TEMP=/home/model-server/tmp
25+
26+
RUN apt-get update \
27+
&& apt-get -y install --no-install-recommends \
28+
build-essential \
29+
ca-certificates \
30+
curl \
31+
git \
32+
libopencv-dev \
33+
openjdk-8-jdk-headless \
34+
vim \
35+
wget \
36+
zlib1g-dev \
37+
&& apt-get clean \
38+
&& rm -rf /var/lib/apt/lists/*
39+
40+
RUN apt-get update \
41+
&& apt-get install -y \
42+
${PYTHON} \
43+
${PYTHON_PIP}
44+
45+
RUN ${PIP} --no-cache-dir install --upgrade \
46+
pip \
47+
setuptools
48+
49+
WORKDIR /
50+
51+
COPY sagemaker_mxnet_serving_container.tar.gz /sagemaker_mxnet_serving_container.tar.gz
52+
53+
RUN ${PIP} install --no-cache-dir \
54+
${MX_URL} \
55+
mxnet-model-server==$MMS_VERSION \
56+
keras-mxnet==2.2.4.1 \
57+
numpy==1.16.5 \
58+
onnx==1.4.1 \
59+
/sagemaker_mxnet_serving_container.tar.gz \
60+
&& rm /sagemaker_mxnet_serving_container.tar.gz
61+
62+
# This is here to make our installed version of OpenCV work.
63+
# https://stackoverflow.com/questions/29274638/opencv-libdc1394-error-failed-to-initialize-libdc1394
64+
# TODO: Should we be installing OpenCV in our image like this? Is there another way we can fix this?
65+
RUN ln -s /dev/null /dev/raw1394
66+
67+
RUN useradd -m model-server \
68+
&& mkdir -p /home/model-server/tmp \
69+
&& chown -R model-server /home/model-server
70+
71+
COPY mms-entrypoint.py /usr/local/bin/dockerd-entrypoint.py
72+
COPY config.properties /home/model-server
73+
COPY deep_learning_container.py /usr/local/bin/deep_learning_container.py
74+
75+
RUN chmod +x /usr/local/bin/dockerd-entrypoint.py \
76+
&& chmod +x /usr/local/bin/deep_learning_container.py
77+
78+
RUN curl https://aws-dlc-licenses.s3.amazonaws.com/mxnet/license.txt -o /license.txt
79+
80+
EXPOSE 8080 8081
81+
ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"]
82+
CMD ["mxnet-model-server", "--start", "--mms-config", "/home/model-server/config.properties"]

docker/1.6.0/py2/Dockerfile.gpu

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
FROM nvidia/cuda:10.1-cudnn7-runtime-ubuntu16.04
2+
3+
LABEL maintainer="Amazon AI"
4+
5+
# Specify accept-bind-to-port LABEL for inference pipelines to use SAGEMAKER_BIND_TO_PORT
6+
# https://docs.aws.amazon.com/sagemaker/latest/dg/inference-pipeline-real-time.html
7+
LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true
8+
9+
ARG MMS_VERSION=1.0.8
10+
ARG MX_URL=https://aws-mxnet-pypi.s3-us-west-2.amazonaws.com/1.6.0/aws_mxnet_cu101mkl-1.6.0rc0-py2.py3-none-manylinux1_x86_64.whl
11+
ARG PYTHON=python
12+
ARG PYTHON_PIP=python-pip
13+
ARG PIP=pip
14+
15+
ENV PYTHONDONTWRITEBYTECODE=1 \
16+
PYTHONUNBUFFERED=1 \
17+
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" \
18+
PYTHONIOENCODING=UTF-8 \
19+
LANG=C.UTF-8 \
20+
LC_ALL=C.UTF-8 \
21+
TEMP=/home/model-server/tmp
22+
23+
RUN apt-get update \
24+
&& apt-get -y install --no-install-recommends \
25+
build-essential \
26+
ca-certificates \
27+
curl \
28+
git \
29+
libopencv-dev \
30+
openjdk-8-jdk-headless \
31+
vim \
32+
wget \
33+
zlib1g-dev \
34+
&& apt-get clean \
35+
&& rm -rf /var/lib/apt/lists/*
36+
37+
RUN apt-get update \
38+
&& apt-get install -y \
39+
${PYTHON} \
40+
${PYTHON_PIP}
41+
42+
RUN ${PIP} --no-cache-dir install --upgrade \
43+
pip \
44+
setuptools
45+
46+
WORKDIR /
47+
48+
COPY sagemaker_mxnet_serving_container.tar.gz /sagemaker_mxnet_serving_container.tar.gz
49+
50+
RUN ${PIP} install --no-cache-dir \
51+
${MX_URL} \
52+
mxnet-model-server==$MMS_VERSION \
53+
keras-mxnet==2.2.4.1 \
54+
numpy==1.16.5 \
55+
onnx==1.4.1 \
56+
/sagemaker_mxnet_serving_container.tar.gz \
57+
&& rm /sagemaker_mxnet_serving_container.tar.gz
58+
59+
# This is here to make our installed version of OpenCV work.
60+
# https://stackoverflow.com/questions/29274638/opencv-libdc1394-error-failed-to-initialize-libdc1394
61+
# TODO: Should we be installing OpenCV in our image like this? Is there another way we can fix this?
62+
RUN ln -s /dev/null /dev/raw1394
63+
64+
RUN useradd -m model-server \
65+
&& mkdir -p /home/model-server/tmp \
66+
&& chown -R model-server /home/model-server
67+
68+
COPY mms-entrypoint.py /usr/local/bin/dockerd-entrypoint.py
69+
COPY config.properties /home/model-server
70+
COPY deep_learning_container.py /usr/local/bin/deep_learning_container.py
71+
72+
RUN chmod +x /usr/local/bin/dockerd-entrypoint.py \
73+
&& chmod +x /usr/local/bin/deep_learning_container.py
74+
75+
RUN curl https://aws-dlc-licenses.s3.amazonaws.com/mxnet/license.txt -o /license.txt
76+
77+
EXPOSE 8080 8081
78+
ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"]
79+
CMD ["mxnet-model-server", "--start", "--mms-config", "/home/model-server/config.properties"]

docker/1.6.0/py2/config.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
vmargs=-Xmx128m -XX:-UseLargePages -XX:+UseG1GC -XX:MaxMetaspaceSize=32M -XX:MaxDirectMemorySize=10m -XX:+ExitOnOutOfMemoryError
2+
model_store=/opt/ml/model
3+
load_models=ALL
4+
inference_address=http://0.0.0.0:8080
5+
management_address=http://0.0.0.0:8081

docker/1.6.0/py2/mms-entrypoint.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2019 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+
14+
import shlex
15+
import subprocess
16+
import sys
17+
import os.path
18+
19+
if not os.path.exists("/opt/ml/input/config"):
20+
subprocess.call(['python', '/usr/local/bin/deep_learning_container.py', '&>/dev/null', '&'])
21+
22+
if sys.argv[1] == 'serve':
23+
from sagemaker_mxnet_serving_container import serving
24+
serving.main()
25+
else:
26+
subprocess.check_call(shlex.split(' '.join(sys.argv[1:])))
27+
28+
# prevent docker exit
29+
subprocess.call(['tail', '-f', '/dev/null'])

docker/1.6.0/py3/Dockerfile.cpu

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
FROM ubuntu:16.04
2+
3+
LABEL maintainer="Amazon AI"
4+
5+
# Specify accept-bind-to-port LABEL for inference pipelines to use SAGEMAKER_BIND_TO_PORT
6+
# https://docs.aws.amazon.com/sagemaker/latest/dg/inference-pipeline-real-time.html
7+
LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true
8+
# Specify multi-models LABEL to indicate container is capable of loading and serving multiple models concurrently
9+
# https://docs.aws.amazon.com/sagemaker/latest/dg/build-multi-model-build-container.html
10+
LABEL com.amazonaws.sagemaker.capabilities.multi-models=true
11+
12+
ARG MMS_VERSION=1.0.8
13+
ARG MX_URL=https://aws-mxnet-pypi.s3-us-west-2.amazonaws.com/1.6.0/aws_mxnet_mkl-1.6.0rc0-py2.py3-none-manylinux1_x86_64.whl
14+
ARG PYTHON=python3
15+
ARG PYTHON_PIP=python3-pip
16+
ARG PIP=pip3
17+
ARG PYTHON_VERSION=3.6.8
18+
19+
ENV PYTHONDONTWRITEBYTECODE=1 \
20+
PYTHONUNBUFFERED=1 \
21+
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" \
22+
PYTHONIOENCODING=UTF-8 \
23+
LANG=C.UTF-8 \
24+
LC_ALL=C.UTF-8 \
25+
TEMP=/home/model-server/tmp
26+
27+
RUN apt-get update \
28+
&& apt-get -y install --no-install-recommends \
29+
build-essential \
30+
ca-certificates \
31+
curl \
32+
git \
33+
libopencv-dev \
34+
openjdk-8-jdk-headless \
35+
vim \
36+
wget \
37+
zlib1g-dev \
38+
&& apt-get clean \
39+
&& rm -rf /var/lib/apt/lists/*
40+
41+
RUN wget https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz \
42+
&& tar -xvf Python-$PYTHON_VERSION.tgz \
43+
&& cd Python-$PYTHON_VERSION \
44+
&& ./configure \
45+
&& make \
46+
&& make install \
47+
&& apt-get update \
48+
&& apt-get install -y --no-install-recommends \
49+
libreadline-gplv2-dev \
50+
libncursesw5-dev \
51+
libssl-dev \
52+
libsqlite3-dev \
53+
tk-dev \
54+
libgdbm-dev \
55+
libc6-dev \
56+
libbz2-dev \
57+
&& make \
58+
&& make install \
59+
&& rm -rf ../Python-$PYTHON_VERSION* \
60+
&& ln -s /usr/local/bin/pip3 /usr/bin/pip
61+
62+
RUN ln -s $(which ${PYTHON}) /usr/local/bin/python
63+
64+
RUN ${PIP} --no-cache-dir install --upgrade \
65+
pip \
66+
setuptools
67+
68+
WORKDIR /
69+
70+
COPY sagemaker_mxnet_serving_container.tar.gz /sagemaker_mxnet_serving_container.tar.gz
71+
72+
RUN ${PIP} install --no-cache-dir \
73+
${MX_URL} \
74+
mxnet-model-server==$MMS_VERSION \
75+
keras-mxnet==2.2.4.1 \
76+
numpy==1.17.4 \
77+
onnx==1.4.1 \
78+
/sagemaker_mxnet_serving_container.tar.gz \
79+
&& rm /sagemaker_mxnet_serving_container.tar.gz
80+
81+
# This is here to make our installed version of OpenCV work.
82+
# https://stackoverflow.com/questions/29274638/opencv-libdc1394-error-failed-to-initialize-libdc1394
83+
# TODO: Should we be installing OpenCV in our image like this? Is there another way we can fix this?
84+
RUN ln -s /dev/null /dev/raw1394
85+
86+
RUN useradd -m model-server \
87+
&& mkdir -p /home/model-server/tmp \
88+
&& chown -R model-server /home/model-server
89+
90+
COPY mms-entrypoint.py /usr/local/bin/dockerd-entrypoint.py
91+
COPY config.properties /home/model-server
92+
COPY deep_learning_container.py /usr/local/bin/deep_learning_container.py
93+
94+
RUN chmod +x /usr/local/bin/dockerd-entrypoint.py \
95+
&& chmod +x /usr/local/bin/deep_learning_container.py
96+
97+
RUN curl https://aws-dlc-licenses.s3.amazonaws.com/mxnet/license.txt -o /license.txt
98+
99+
EXPOSE 8080 8081
100+
ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"]
101+
CMD ["mxnet-model-server", "--start", "--mms-config", "/home/model-server/config.properties"]

0 commit comments

Comments
 (0)