Skip to content

Commit 0f6d86d

Browse files
authored
Merge branch 'master' into regional-fixes
2 parents db57952 + 8acf51d commit 0f6d86d

File tree

14 files changed

+578
-30
lines changed

14 files changed

+578
-30
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
*pyc
22
dist
33
**/*.egg-info
4+
.DS_Store
5+
.idea/
6+
*.iml

README.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ Base Images
6363
~~~~~~~~~~~
6464

6565
The "base" Dockerfile encompass the installation of the framework and all of the dependencies
66-
needed.
66+
needed. It is needed before building image for TensorFlow 1.8.0 and before.
67+
Building a base image is not required for images for TensorFlow 1.9.0 and onwards.
6768

6869
Tagging scheme is based on <tensorflow_version>-<processor>-<python_version>. (e.g. 1.4
6970
.1-cpu-py2)
@@ -98,7 +99,7 @@ Final Images
9899

99100
The "final" Dockerfiles encompass the installation of the SageMaker specific support code.
100101

101-
All “final” Dockerfiles use `base images for building <https://github
102+
For images of TensorFlow 1.8.0 and before, all “final” Dockerfiles use `base images for building <https://github
102103
.com/aws/sagemaker-tensorflow-containers/blob/master/docker/1.4.1/final/py2/Dockerfile.cpu#L2>`__.
103104

104105
These “base” images are specified with the naming convention of
@@ -107,7 +108,9 @@ tensorflow-base:<tensorflow_version>-<processor>-<python_version>.
107108
Before building “final” images:
108109

109110
Build your “base” image. Make sure it is named and tagged in accordance with your “final”
110-
Dockerfile.
111+
Dockerfile. Skip this step if you want to build image of Tensorflow Version 1.9.0 and above.
112+
113+
Then prepare the SageMaker TensorFlow Container python package in the image folder like below:
111114

112115
::
113116

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
FROM ubuntu:16.04
2+
3+
MAINTAINER Amazon AI
4+
5+
ARG framework_installable
6+
ARG framework_support_installable=sagemaker_tensorflow_container-1.0.0.tar.gz
7+
8+
WORKDIR /root
9+
10+
COPY $framework_installable .
11+
COPY $framework_support_installable .
12+
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
build-essential \
15+
curl \
16+
git \
17+
libcurl3-dev \
18+
libfreetype6-dev \
19+
libpng12-dev \
20+
libzmq3-dev \
21+
pkg-config \
22+
python-dev \
23+
rsync \
24+
software-properties-common \
25+
unzip \
26+
zip \
27+
zlib1g-dev \
28+
openjdk-8-jdk \
29+
openjdk-8-jre-headless \
30+
wget \
31+
vim \
32+
iputils-ping \
33+
nginx \
34+
&& \
35+
apt-get clean && \
36+
rm -rf /var/lib/apt/lists/*
37+
38+
RUN curl -fSsL -O https://bootstrap.pypa.io/get-pip.py && \
39+
python get-pip.py && \
40+
rm get-pip.py
41+
42+
RUN pip --no-cache-dir install \
43+
numpy \
44+
scipy \
45+
sklearn \
46+
pandas \
47+
Pillow \
48+
h5py
49+
50+
# TODO: upgrade to tf serving 1.8, which requires more work with updating
51+
# dependencies. See current work in progress in tfserving-1.8 branch.
52+
ENV TF_SERVING_VERSION=1.7.0
53+
54+
RUN pip install numpy boto3 six awscli flask==0.11 Jinja2==2.9 tensorflow-serving-api==$TF_SERVING_VERSION gevent gunicorn
55+
56+
RUN wget "http://storage.googleapis.com/tensorflow-serving-apt/pool/tensorflow-model-server/t/tensorflow-model-server/tensorflow-model-server_${TF_SERVING_VERSION}_all.deb" && \
57+
dpkg -i tensorflow-model-server_${TF_SERVING_VERSION}_all.deb
58+
59+
# Update libstdc++6, as required by tensorflow-serving >= 1.6: https://github.com/tensorflow/serving/issues/819
60+
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
61+
apt-get update && \
62+
apt-get install -y libstdc++6
63+
64+
RUN framework_installable_local=$(basename $framework_installable) && \
65+
framework_support_installable_local=$(basename $framework_support_installable) && \
66+
\
67+
pip install --no-cache --upgrade $framework_installable_local && \
68+
pip install $framework_support_installable_local && \
69+
pip install "sagemaker-tensorflow>=1.10,<1.11" &&\
70+
\
71+
rm $framework_installable_local && \
72+
rm $framework_support_installable_local
73+
74+
# Set environment variables for MKL
75+
# TODO: investigate the right value for OMP_NUM_THREADS
76+
ENV KMP_AFFINITY=granularity=fine,compact,1,0 KMP_BLOCKTIME=1 KMP_SETTINGS=0
77+
78+
# entry.py comes from sagemaker-container-support
79+
ENTRYPOINT ["entry.py"]
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
FROM nvidia/cuda:9.0-base-ubuntu16.04
2+
3+
MAINTAINER Amazon AI
4+
5+
ARG framework_installable
6+
ARG framework_support_installable=sagemaker_tensorflow_container-1.0.0.tar.gz
7+
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
build-essential \
10+
cuda-command-line-tools-9-0 \
11+
cuda-cublas-dev-9-0 \
12+
cuda-cudart-dev-9-0 \
13+
cuda-cufft-dev-9-0 \
14+
cuda-curand-dev-9-0 \
15+
cuda-cusolver-dev-9-0 \
16+
cuda-cusparse-dev-9-0 \
17+
curl \
18+
git \
19+
libcudnn7=7.1.4.18-1+cuda9.0 \
20+
libcudnn7-dev=7.1.4.18-1+cuda9.0 \
21+
libcurl3-dev \
22+
libfreetype6-dev \
23+
libpng12-dev \
24+
libzmq3-dev \
25+
pkg-config \
26+
python-dev \
27+
rsync \
28+
software-properties-common \
29+
unzip \
30+
zip \
31+
zlib1g-dev \
32+
wget \
33+
vim \
34+
nginx \
35+
iputils-ping \
36+
&& \
37+
rm -rf /var/lib/apt/lists/* && \
38+
find /usr/local/cuda-9.0/lib64/ -type f -name 'lib*_static.a' -not -name 'libcudart_static.a' -delete && \
39+
rm /usr/lib/x86_64-linux-gnu/libcudnn_static_v7.a
40+
41+
RUN curl -fSsL -O https://bootstrap.pypa.io/get-pip.py && \
42+
python get-pip.py && \
43+
rm get-pip.py
44+
45+
RUN pip --no-cache-dir install \
46+
numpy \
47+
scipy \
48+
sklearn \
49+
pandas \
50+
Pillow \
51+
h5py
52+
53+
# Set up grpc
54+
RUN pip install enum34 futures mock six && \
55+
pip install --pre 'protobuf>=3.0.0a3' && \
56+
pip install -i https://testpypi.python.org/simple --pre grpcio
57+
58+
# Set up Bazel.
59+
60+
# Running bazel inside a `docker build` command causes trouble, cf:
61+
# https://github.com/bazelbuild/bazel/issues/134
62+
# The easiest solution is to set up a bazelrc file forcing --batch.
63+
RUN echo "startup --batch" >>/etc/bazel.bazelrc
64+
# Similarly, we need to workaround sandboxing issues:
65+
# https://github.com/bazelbuild/bazel/issues/418
66+
RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
67+
>>/etc/bazel.bazelrc
68+
# Install the most recent bazel release which works: https://github.com/bazelbuild/bazel/issues/4652
69+
ENV BAZEL_VERSION 0.10.1
70+
WORKDIR /
71+
RUN mkdir /bazel && \
72+
cd /bazel && \
73+
curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
74+
curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -o /bazel/LICENSE.txt https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE && \
75+
chmod +x bazel-*.sh && \
76+
./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
77+
cd / && \
78+
rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
79+
80+
# Configure the build for our CUDA configuration.
81+
ENV CI_BUILD_PYTHON python
82+
ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
83+
ENV TF_NEED_CUDA 1
84+
ENV TF_CUDA_COMPUTE_CAPABILITIES=3.7,6.1
85+
ENV TF_CUDA_VERSION=9.0
86+
ENV TF_CUDNN_VERSION=7
87+
ENV CUDNN_INSTALL_PATH=/usr/lib/x86_64-linux-gnu
88+
89+
# TODO: upgrade to tf serving 1.8, which requires more work with updating
90+
# dependencies. See current work in progress in tfserving-1.8 branch.
91+
ENV TF_SERVING_VERSION=1.7.0
92+
93+
# Install tensorflow-serving-api
94+
RUN pip install tensorflow-serving-api==$TF_SERVING_VERSION
95+
96+
# Download TensorFlow Serving
97+
RUN cd / && git clone --recurse-submodules https://github.com/tensorflow/serving && \
98+
cd serving && \
99+
git checkout $TF_SERVING_VERSION
100+
101+
# Configure Tensorflow to use the GPU
102+
WORKDIR /serving
103+
RUN git clone --recursive https://github.com/tensorflow/tensorflow.git && \
104+
cd tensorflow && \
105+
git checkout v$TF_SERVING_VERSION && \
106+
tensorflow/tools/ci_build/builds/configured GPU
107+
108+
# Build TensorFlow Serving and Install it in /usr/local/bin
109+
WORKDIR /serving
110+
RUN bazel build -c opt --config=cuda \
111+
--cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \
112+
--crosstool_top=@local_config_cuda//crosstool:toolchain \
113+
tensorflow_serving/model_servers:tensorflow_model_server && \
114+
cp bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server /usr/local/bin/ && \
115+
bazel clean --expunge
116+
117+
# Update libstdc++6, as required by tensorflow-serving >= 1.6: https://github.com/tensorflow/serving/issues/819
118+
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
119+
apt-get update && \
120+
apt-get install -y libstdc++6
121+
122+
# cleaning up the container
123+
RUN rm -rf /serving && \
124+
rm -rf /bazel
125+
126+
WORKDIR /root
127+
128+
# Will install from pypi once packages are released there. For now, copy from local file system.
129+
COPY $framework_installable .
130+
COPY $framework_support_installable .
131+
132+
RUN framework_installable_local=$(basename $framework_installable) && \
133+
framework_support_installable_local=$(basename $framework_support_installable) && \
134+
\
135+
pip install --no-cache --upgrade $framework_installable_local && \
136+
pip install $framework_support_installable_local && \
137+
pip install "sagemaker-tensorflow>=1.10,<1.11" &&\
138+
\
139+
rm $framework_installable_local && \
140+
rm $framework_support_installable_local
141+
142+
# entry.py comes from sagemaker-container-support
143+
ENTRYPOINT ["entry.py"]

docker/1.9.0/final/py2/Dockerfile.cpu

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
FROM ubuntu:16.04
2+
3+
MAINTAINER Amazon AI
4+
5+
ARG framework_installable
6+
ARG framework_support_installable=sagemaker_tensorflow_container-1.0.0.tar.gz
7+
8+
WORKDIR /root
9+
10+
COPY $framework_installable .
11+
COPY $framework_support_installable .
12+
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
build-essential \
15+
curl \
16+
git \
17+
libcurl3-dev \
18+
libfreetype6-dev \
19+
libpng12-dev \
20+
libzmq3-dev \
21+
pkg-config \
22+
python-dev \
23+
rsync \
24+
software-properties-common \
25+
unzip \
26+
zip \
27+
zlib1g-dev \
28+
openjdk-8-jdk \
29+
openjdk-8-jre-headless \
30+
wget \
31+
vim \
32+
iputils-ping \
33+
nginx \
34+
&& \
35+
apt-get clean && \
36+
rm -rf /var/lib/apt/lists/*
37+
38+
RUN curl -fSsL -O https://bootstrap.pypa.io/get-pip.py && \
39+
python get-pip.py && \
40+
rm get-pip.py
41+
42+
RUN pip --no-cache-dir install \
43+
numpy \
44+
scipy \
45+
sklearn \
46+
pandas \
47+
Pillow \
48+
h5py
49+
50+
# TODO: upgrade to tf serving 1.8, which requires more work with updating
51+
# dependencies. See current work in progress in tfserving-1.8 branch.
52+
ENV TF_SERVING_VERSION=1.7.0
53+
54+
RUN pip install numpy boto3 six awscli flask==0.11 Jinja2==2.9 tensorflow-serving-api==$TF_SERVING_VERSION gevent gunicorn
55+
56+
RUN wget "http://storage.googleapis.com/tensorflow-serving-apt/pool/tensorflow-model-server/t/tensorflow-model-server/tensorflow-model-server_${TF_SERVING_VERSION}_all.deb" && \
57+
dpkg -i tensorflow-model-server_${TF_SERVING_VERSION}_all.deb
58+
59+
# Update libstdc++6, as required by tensorflow-serving >= 1.6: https://github.com/tensorflow/serving/issues/819
60+
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
61+
apt-get update && \
62+
apt-get install -y libstdc++6
63+
64+
RUN framework_installable_local=$(basename $framework_installable) && \
65+
framework_support_installable_local=$(basename $framework_support_installable) && \
66+
\
67+
pip install --no-cache --upgrade $framework_installable_local && \
68+
pip install $framework_support_installable_local && \
69+
pip install "sagemaker-tensorflow>=1.9,<1.10" &&\
70+
\
71+
rm $framework_installable_local && \
72+
rm $framework_support_installable_local
73+
74+
# Set environment variables for MKL
75+
# TODO: investigate the right value for OMP_NUM_THREADS
76+
ENV KMP_AFFINITY=granularity=fine,compact,1,0 KMP_BLOCKTIME=1 KMP_SETTINGS=0
77+
78+
# entry.py comes from sagemaker-container-support
79+
ENTRYPOINT ["entry.py"]

0 commit comments

Comments
 (0)