|
| 1 | +FROM nvidia/cuda:9.0-base-ubuntu16.04 |
| 2 | + |
| 3 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 4 | + build-essential \ |
| 5 | + cuda-command-line-tools-9-0 \ |
| 6 | + cuda-cublas-dev-9-0 \ |
| 7 | + cuda-cudart-dev-9-0 \ |
| 8 | + cuda-cufft-dev-9-0 \ |
| 9 | + cuda-curand-dev-9-0 \ |
| 10 | + cuda-cusolver-dev-9-0 \ |
| 11 | + cuda-cusparse-dev-9-0 \ |
| 12 | + curl \ |
| 13 | + git \ |
| 14 | + libcudnn7=7.0.5.15-1+cuda9.0 \ |
| 15 | + libcudnn7-dev=7.0.5.15-1+cuda9.0 \ |
| 16 | + libcurl3-dev \ |
| 17 | + libfreetype6-dev \ |
| 18 | + libpng12-dev \ |
| 19 | + libzmq3-dev \ |
| 20 | + pkg-config \ |
| 21 | + python-dev \ |
| 22 | + rsync \ |
| 23 | + software-properties-common \ |
| 24 | + unzip \ |
| 25 | + zip \ |
| 26 | + zlib1g-dev \ |
| 27 | + wget \ |
| 28 | + vim \ |
| 29 | + nginx \ |
| 30 | + iputils-ping \ |
| 31 | + && \ |
| 32 | + rm -rf /var/lib/apt/lists/* && \ |
| 33 | + find /usr/local/cuda-9.0/lib64/ -type f -name 'lib*_static.a' -not -name 'libcudart_static.a' -delete && \ |
| 34 | + rm /usr/lib/x86_64-linux-gnu/libcudnn_static_v7.a |
| 35 | + |
| 36 | +RUN curl -fSsL -O https://bootstrap.pypa.io/get-pip.py && \ |
| 37 | + python get-pip.py && \ |
| 38 | + rm get-pip.py |
| 39 | + |
| 40 | +RUN pip --no-cache-dir install \ |
| 41 | + numpy \ |
| 42 | + scipy \ |
| 43 | + sklearn \ |
| 44 | + pandas \ |
| 45 | + h5py |
| 46 | + |
| 47 | +# Set up grpc |
| 48 | +RUN pip install enum34 futures mock six && \ |
| 49 | + pip install --pre 'protobuf>=3.0.0a3' && \ |
| 50 | + pip install -i https://testpypi.python.org/simple --pre grpcio |
| 51 | + |
| 52 | +# Set up Bazel. |
| 53 | + |
| 54 | +# Running bazel inside a `docker build` command causes trouble, cf: |
| 55 | +# https://github.com/bazelbuild/bazel/issues/134 |
| 56 | +# The easiest solution is to set up a bazelrc file forcing --batch. |
| 57 | +RUN echo "startup --batch" >>/etc/bazel.bazelrc |
| 58 | +# Similarly, we need to workaround sandboxing issues: |
| 59 | +# https://github.com/bazelbuild/bazel/issues/418 |
| 60 | +RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \ |
| 61 | + >>/etc/bazel.bazelrc |
| 62 | +# Install the most recent bazel release which works: https://github.com/bazelbuild/bazel/issues/4652 |
| 63 | +ENV BAZEL_VERSION 0.10.1 |
| 64 | +WORKDIR / |
| 65 | +RUN mkdir /bazel && \ |
| 66 | + cd /bazel && \ |
| 67 | + 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 && \ |
| 68 | + 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 && \ |
| 69 | + chmod +x bazel-*.sh && \ |
| 70 | + ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ |
| 71 | + cd / && \ |
| 72 | + rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh |
| 73 | + |
| 74 | +# Configure the build for our CUDA configuration. |
| 75 | +ENV CI_BUILD_PYTHON python |
| 76 | +ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH |
| 77 | +ENV TF_NEED_CUDA 1 |
| 78 | +ENV TF_CUDA_COMPUTE_CAPABILITIES=3.7,6.1 |
| 79 | +ENV TF_CUDA_VERSION=9.0 |
| 80 | +ENV TF_CUDNN_VERSION=7 |
| 81 | +ENV CUDNN_INSTALL_PATH=/usr/lib/x86_64-linux-gnu |
| 82 | + |
| 83 | +# TODO: upgrade to tf serving 1.8, which requires more work with updating |
| 84 | +# dependencies. See current work in progress in tfserving-1.8 branch. |
| 85 | +ENV TF_SERVING_VERSION=1.7.0 |
| 86 | + |
| 87 | +# Install tensorflow-serving-api |
| 88 | +RUN pip install tensorflow-serving-api==$TF_SERVING_VERSION |
| 89 | + |
| 90 | +# Download TensorFlow Serving |
| 91 | +RUN cd / && git clone --recurse-submodules https://github.com/tensorflow/serving && \ |
| 92 | + cd serving && \ |
| 93 | + git checkout $TF_SERVING_VERSION |
| 94 | + |
| 95 | +# Configure Tensorflow to use the GPU |
| 96 | +WORKDIR /serving |
| 97 | +RUN git clone --recursive https://github.com/tensorflow/tensorflow.git && \ |
| 98 | + cd tensorflow && \ |
| 99 | + git checkout v$TF_SERVING_VERSION && \ |
| 100 | + tensorflow/tools/ci_build/builds/configured GPU |
| 101 | + |
| 102 | +# Build TensorFlow Serving and Install it in /usr/local/bin |
| 103 | +WORKDIR /serving |
| 104 | +RUN bazel build -c opt --config=cuda \ |
| 105 | + --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \ |
| 106 | + --crosstool_top=@local_config_cuda//crosstool:toolchain \ |
| 107 | + tensorflow_serving/model_servers:tensorflow_model_server && \ |
| 108 | + cp bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server /usr/local/bin/ && \ |
| 109 | + bazel clean --expunge |
| 110 | + |
| 111 | +# Update libstdc++6, as required by tensorflow-serving >= 1.6: https://github.com/tensorflow/serving/issues/819 |
| 112 | +RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ |
| 113 | + apt-get update && \ |
| 114 | + apt-get install -y libstdc++6 |
| 115 | + |
| 116 | +# cleaning up the container |
| 117 | +RUN rm -rf /serving && \ |
| 118 | + rm -rf /bazel |
| 119 | + |
0 commit comments