Skip to content

Add TensorFlow 1.7 dockerfiles #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 20, 2018
51 changes: 51 additions & 0 deletions docker/1.7.0/base/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
libcurl3-dev \
libfreetype6-dev \
libpng12-dev \
libzmq3-dev \
pkg-config \
python-dev \
rsync \
software-properties-common \
unzip \
zip \
zlib1g-dev \
openjdk-8-jdk \
openjdk-8-jre-headless \
wget \
vim \
iputils-ping \
nginx \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN curl -fSsL -O https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm get-pip.py

RUN pip --no-cache-dir install \
numpy \
scipy \
sklearn \
pandas \
h5py

WORKDIR /root

ENV TF_SERVING_VERSION=1.7.0

RUN pip install numpy boto3 six awscli flask==0.11 Jinja2==2.9 tensorflow-serving-api==$TF_SERVING_VERSION gevent gunicorn

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" && \
dpkg -i tensorflow-model-server_${TF_SERVING_VERSION}_all.deb

# Update libstdc++6, as required by tensorflow-serving >= 1.6: https://github.com/tensorflow/serving/issues/819
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
apt-get update && \
apt-get install -y libstdc++6
117 changes: 117 additions & 0 deletions docker/1.7.0/base/Dockerfile.gpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
FROM nvidia/cuda:9.0-base-ubuntu16.04

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cuda-command-line-tools-9-0 \
cuda-cublas-dev-9-0 \
cuda-cudart-dev-9-0 \
cuda-cufft-dev-9-0 \
cuda-curand-dev-9-0 \
cuda-cusolver-dev-9-0 \
cuda-cusparse-dev-9-0 \
curl \
git \
libcudnn7=7.0.5.15-1+cuda9.0 \
libcudnn7-dev=7.0.5.15-1+cuda9.0 \
libcurl3-dev \
libfreetype6-dev \
libpng12-dev \
libzmq3-dev \
pkg-config \
python-dev \
rsync \
software-properties-common \
unzip \
zip \
zlib1g-dev \
wget \
vim \
nginx \
iputils-ping \
&& \
rm -rf /var/lib/apt/lists/* && \
find /usr/local/cuda-9.0/lib64/ -type f -name 'lib*_static.a' -not -name 'libcudart_static.a' -delete && \
rm /usr/lib/x86_64-linux-gnu/libcudnn_static_v7.a

RUN curl -fSsL -O https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm get-pip.py

RUN pip --no-cache-dir install \
numpy \
scipy \
sklearn \
pandas \
h5py

# Set up grpc
RUN pip install enum34 futures mock six && \
pip install --pre 'protobuf>=3.0.0a3' && \
pip install -i https://testpypi.python.org/simple --pre grpcio

# Set up Bazel.

# Running bazel inside a `docker build` command causes trouble, cf:
# https://github.com/bazelbuild/bazel/issues/134
# The easiest solution is to set up a bazelrc file forcing --batch.
RUN echo "startup --batch" >>/etc/bazel.bazelrc
# Similarly, we need to workaround sandboxing issues:
# https://github.com/bazelbuild/bazel/issues/418
RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
>>/etc/bazel.bazelrc
# Install the most recent bazel release which works: https://github.com/bazelbuild/bazel/issues/4652
ENV BAZEL_VERSION 0.10.1
WORKDIR /
RUN mkdir /bazel && \
cd /bazel && \
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 && \
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 && \
chmod +x bazel-*.sh && \
./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
cd / && \
rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh

# Configure the build for our CUDA configuration.
ENV CI_BUILD_PYTHON python
ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
ENV TF_NEED_CUDA 1
ENV TF_CUDA_COMPUTE_CAPABILITIES=3.7,6.1
ENV TF_CUDA_VERSION=9.0
ENV TF_CUDNN_VERSION=7
ENV CUDNN_INSTALL_PATH=/usr/lib/x86_64-linux-gnu

ENV TF_SERVING_VERSION=1.7.0

# Install tensorflow-serving-api
RUN pip install tensorflow-serving-api==$TF_SERVING_VERSION

# Download TensorFlow Serving
RUN cd / && git clone --recurse-submodules https://github.com/tensorflow/serving && \
cd serving && \
git checkout $TF_SERVING_VERSION

# Configure Tensorflow to use the GPU
WORKDIR /serving
RUN git clone --recursive https://github.com/tensorflow/tensorflow.git && \
cd tensorflow && \
git checkout v$TF_SERVING_VERSION && \
tensorflow/tools/ci_build/builds/configured GPU

# Build TensorFlow Serving and Install it in /usr/local/bin
WORKDIR /serving
RUN bazel build -c opt --config=cuda \
--cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \
--crosstool_top=@local_config_cuda//crosstool:toolchain \
tensorflow_serving/model_servers:tensorflow_model_server && \
cp bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server /usr/local/bin/ && \
bazel clean --expunge

# Update libstdc++6, as required by tensorflow-serving >= 1.6: https://github.com/tensorflow/serving/issues/819
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
apt-get update && \
apt-get install -y libstdc++6

# cleaning up the container
RUN rm -rf /serving && \
rm -rf /bazel

24 changes: 24 additions & 0 deletions docker/1.7.0/final/py2/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use local version of image built from Dockerfile.cpu in /docker/1.7.0/base
FROM tensorflow-base:1.7.0-cpu-py2
MAINTAINER Amazon AI

ARG framework_installable
ARG framework_support_installable=sagemaker_tensorflow_container-1.0.0.tar.gz

WORKDIR /root

# Will install from pypi once packages are released there. For now, copy from local file system.
COPY $framework_installable .
COPY $framework_support_installable .

RUN framework_installable_local=$(basename $framework_installable) && \
framework_support_installable_local=$(basename $framework_support_installable) && \
\
pip install $framework_installable_local && \
pip install $framework_support_installable_local && \
\
rm $framework_installable_local && \
rm $framework_support_installable_local

# entry.py comes from sagemaker-container-support
ENTRYPOINT ["entry.py"]
25 changes: 25 additions & 0 deletions docker/1.7.0/final/py2/Dockerfile.gpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use local version of image built from Dockerfile.gpu in /docker/1.6.0/base
FROM tensorflow-base:1.7.0-gpu-py2
MAINTAINER Amazon AI

ARG framework_installable
ARG framework_support_installable=sagemaker_tensorflow_container-1.0.0.tar.gz

WORKDIR /root

# Will install from pypi once packages are released there. For now, copy from local file system.
COPY $framework_installable .
COPY $framework_support_installable .

RUN framework_installable_local=$(basename $framework_installable) && \
framework_support_installable_local=$(basename $framework_support_installable) && \
\
pip install $framework_installable_local && \
pip install $framework_support_installable_local && \
\
rm $framework_installable_local && \
rm $framework_support_installable_local

# entry.py comes from sagemaker-container-support
ENTRYPOINT ["entry.py"]

3 changes: 3 additions & 0 deletions test/integ/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def required_versions(framework_version):
elif framework_version == '1.6.0':
return ['tensorflow-serving-api==1.5.0',
'tensorflow==1.6.0']
elif framework_version == '1.7.0':
return ['tensorflow-serving-api==1.7.0',
'tensorflow==1.7.0']
else:
raise ValueError("invalid internal test config")

Expand Down