|
| 1 | +FROM tensorflow/serving:1.12.0-gpu as tensorflow_serving_image |
| 2 | +FROM nvidia/cuda:9.0-base-ubuntu16.04 |
| 3 | + |
| 4 | +LABEL maintainer="Amazon AI" |
| 5 | +LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true |
| 6 | + |
| 7 | +ARG framework_installable |
| 8 | +ARG framework_support_installable=sagemaker_tensorflow_container-1.0.0.tar.gz |
| 9 | + |
| 10 | +ENV NCCL_VERSION=2.3.5-2+cuda9.0 |
| 11 | +ENV CUDNN_VERSION=7.3.1.20-1+cuda9.0 |
| 12 | +ENV TF_TENSORRT_VERSION=4.1.2 |
| 13 | + |
| 14 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 15 | + ca-certificates \ |
| 16 | + cuda-command-line-tools-9-0 \ |
| 17 | + cuda-cublas-9-0 \ |
| 18 | + cuda-cufft-9-0 \ |
| 19 | + cuda-curand-9-0 \ |
| 20 | + cuda-cusolver-9-0 \ |
| 21 | + cuda-cusparse-9-0 \ |
| 22 | + libcudnn7=${CUDNN_VERSION} \ |
| 23 | + libnccl2=${NCCL_VERSION} \ |
| 24 | + libgomp1 \ |
| 25 | + python \ |
| 26 | + curl \ |
| 27 | + nginx \ |
| 28 | + && \ |
| 29 | +# The 'apt-get install' of nvinfer-runtime-trt-repo-ubuntu1604-4.0.1-ga-cuda9.0 |
| 30 | +# adds a new list which contains libnvinfer library, so it needs another |
| 31 | +# 'apt-get update' to retrieve that list before it can actually install the |
| 32 | +# library. |
| 33 | +# We don't install libnvinfer-dev since we don't need to build against TensorRT, |
| 34 | +# and libnvinfer4 doesn't contain libnvinfer.a static library. |
| 35 | + apt-get update && apt-get install -y --no-install-recommends \ |
| 36 | + nvinfer-runtime-trt-repo-ubuntu1604-4.0.1-ga-cuda9.0 && \ |
| 37 | + apt-get update && apt-get install -y --no-install-recommends \ |
| 38 | + libnvinfer4=${TF_TENSORRT_VERSION}-1+cuda9.0 && \ |
| 39 | + apt-get clean && \ |
| 40 | + rm -rf /var/lib/apt/lists/* && \ |
| 41 | + rm /usr/lib/x86_64-linux-gnu/libnvinfer_plugin* && \ |
| 42 | + rm /usr/lib/x86_64-linux-gnu/libnvcaffe_parser* && \ |
| 43 | + rm /usr/lib/x86_64-linux-gnu/libnvparsers* |
| 44 | + |
| 45 | +# Python won’t try to write .pyc or .pyo files on the import of source modules |
| 46 | +ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 |
| 47 | + |
| 48 | +# Removing tests to free some space |
| 49 | +RUN set -ex; \ |
| 50 | + curl -k -O https://bootstrap.pypa.io/get-pip.py && \ |
| 51 | + python get-pip.py \ |
| 52 | + --disable-pip-version-check \ |
| 53 | + --no-cache-dir \ |
| 54 | + "pip==18.1" \ |
| 55 | + ; \ |
| 56 | + pip --version; \ |
| 57 | + find /usr/local -depth \ |
| 58 | + \( \ |
| 59 | + \( -type d -a \( -name test -o -name tests \) \) \ |
| 60 | + -o \ |
| 61 | + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ |
| 62 | + \) -exec rm -rf '{}' +; \ |
| 63 | + rm -f get-pip.py |
| 64 | + |
| 65 | +WORKDIR / |
| 66 | + |
| 67 | +# Install TF Serving pkg |
| 68 | +COPY --from=tensorflow_serving_image /usr/bin/tensorflow_model_server /usr/bin/tensorflow_model_server |
| 69 | + |
| 70 | + |
| 71 | +COPY $framework_installable . |
| 72 | +COPY $framework_support_installable . |
| 73 | + |
| 74 | +RUN pip install -U --no-cache-dir \ |
| 75 | + numpy \ |
| 76 | + scipy \ |
| 77 | + sklearn \ |
| 78 | + pandas \ |
| 79 | + Pillow \ |
| 80 | + h5py \ |
| 81 | + tensorflow-serving-api==1.12.0 \ |
| 82 | + \ |
| 83 | + $framework_installable \ |
| 84 | + $framework_support_installable \ |
| 85 | + "sagemaker-tensorflow>=1.12,<1.13" && \ |
| 86 | + \ |
| 87 | + rm $framework_installable && \ |
| 88 | + rm $framework_support_installable && \ |
| 89 | + pip uninstall -y --no-cache-dir \ |
| 90 | + markdown \ |
| 91 | + tensorboard |
| 92 | + |
| 93 | +# entry.py comes from sagemaker-container-support |
| 94 | +ENTRYPOINT ["entry.py"] |
0 commit comments