devel-gpu-jupyter.Dockerfile 6.6 KB
Newer Older
1
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
A
Austin Anderson 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
#
16
# THIS IS A GENERATED DOCKERFILE.
A
Austin Anderson 已提交
17
#
18
# This file was assembled from multiple pieces, whose use is documented
J
John Lin 已提交
19
# throughout. Please refer to the TensorFlow dockerfiles documentation
20
# for more information.
21

22
ARG UBUNTU_VERSION=18.04
23

24
ARG ARCH=
25
ARG CUDA=10.1
26
FROM nvidia/cuda${ARCH:+-$ARCH}:${CUDA}-base-ubuntu${UBUNTU_VERSION} as base
A
Austin Anderson 已提交
27 28 29 30
# ARCH and CUDA are specified again because the FROM directive resets ARGs
# (but their default value is retained if set previously)
ARG ARCH
ARG CUDA
31
ARG CUDNN=7.6.4.38-1
32 33
ARG CUDNN_MAJOR_VERSION=7
ARG LIB_DIR_PREFIX=x86_64
34 35
ARG LIBNVINFER=6.0.1-1
ARG LIBNVINFER_MAJOR_VERSION=6
36

37
# Needed for string substitution
38
SHELL ["/bin/bash", "-c"]
39 40
RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential \
41
        cuda-command-line-tools-${CUDA/./-} \
A
Austin Anderson 已提交
42 43 44 45 46 47 48
        # There appears to be a regression in libcublas10=10.2.2.89-1 which
        # prevents cublas from initializing in TF. See
        # https://github.com/tensorflow/tensorflow/issues/9489#issuecomment-562394257
        libcublas10=10.2.1.243-1 \ 
        libcublas-dev=10.2.1.243-1 \
        cuda-nvrtc-${CUDA/./-} \
        cuda-nvrtc-dev-${CUDA/./-} \
49 50 51 52 53 54 55
        cuda-cudart-dev-${CUDA/./-} \
        cuda-cufft-dev-${CUDA/./-} \
        cuda-curand-dev-${CUDA/./-} \
        cuda-cusolver-dev-${CUDA/./-} \
        cuda-cusparse-dev-${CUDA/./-} \
        libcudnn7=${CUDNN}+cuda${CUDA} \
        libcudnn7-dev=${CUDNN}+cuda${CUDA} \
56 57 58 59 60 61 62 63 64 65 66
        libcurl3-dev \
        libfreetype6-dev \
        libhdf5-serial-dev \
        libzmq3-dev \
        pkg-config \
        rsync \
        software-properties-common \
        unzip \
        zip \
        zlib1g-dev \
        wget \
T
Toby Boyd 已提交
67
        git \
68
        && \
69 70
    find /usr/local/cuda-${CUDA}/lib64/ -type f -name 'lib*_static.a' -not -name 'libcudart_static.a' -delete && \
    rm /usr/lib/${LIB_DIR_PREFIX}-linux-gnu/libcudnn_static_v7.a
71

72
# Install TensorRT if not building for PowerPC
73
RUN [[ "${ARCH}" = "ppc64le" ]] || { apt-get update && \
74 75 76 77
        apt-get install -y --no-install-recommends libnvinfer${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} \
        libnvinfer-dev=${LIBNVINFER}+cuda${CUDA} \
        libnvinfer-plugin-dev=${LIBNVINFER}+cuda${CUDA} \
        libnvinfer-plugin${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} \
78
        && apt-get clean \
79
        && rm -rf /var/lib/apt/lists/*; }
80

81
# Configure the build for our CUDA configuration.
82
ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs:/usr/include/x64_64-linux-gnu:$LD_LIBRARY_PATH
83
ENV TF_NEED_CUDA 1
84
ENV TF_NEED_TENSORRT 1
85
ENV TF_CUDA_VERSION=${CUDA}
86
ENV TF_CUDNN_VERSION=${CUDNN_MAJOR_VERSION}
87 88
# CACHE_STOP is used to rerun future commands, otherwise cloning tensorflow will be cached and will not pull the most recent version
ARG CACHE_STOP=1
89
# Check out TensorFlow source code if --build-arg CHECKOUT_TF_SRC=1
90
ARG CHECKOUT_TF_SRC=0
91
RUN test "${CHECKOUT_TF_SRC}" -eq 1 && git clone https://github.com/tensorflow/tensorflow.git /tensorflow_src || true
92

93 94 95 96 97 98
# Link the libcuda stub to the location where tensorflow is searching for it and reconfigure
# dynamic linker run-time bindings
RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 \
    && echo "/usr/local/cuda/lib64/stubs" > /etc/ld.so.conf.d/z-cuda-stubs.conf \
    && ldconfig

Y
Yong Tang 已提交
99 100 101
# See http://bugs.python.org/issue19846
ENV LANG C.UTF-8

102
RUN apt-get update && apt-get install -y \
A
Austin Anderson 已提交
103
    python3 \
104
    python3-pip
105

106
RUN python3 -m pip --no-cache-dir install --upgrade \
107 108 109
    pip \
    setuptools

110
# Some TF tools expect a "python" binary
111
RUN ln -s $(which python3) /usr/local/bin/python
112

113 114 115 116
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    git \
T
Toby Boyd 已提交
117
    wget \
118
    openjdk-8-jdk \
119
    python3-dev \
120
    virtualenv \
121 122
    swig

123
RUN python3 -m pip --no-cache-dir install \
124 125 126 127 128
    Pillow \
    h5py \
    keras_preprocessing \
    matplotlib \
    mock \
A
Austin Anderson 已提交
129
    'numpy<1.19.0' \
130 131 132
    scipy \
    sklearn \
    pandas \
133
    future \
134
    portpicker \
135 136
    enum34

137
# Install bazel
138
ARG BAZEL_VERSION=3.1.0
T
Toby Boyd 已提交
139 140 141 142 143 144
RUN mkdir /bazel && \
    wget -O /bazel/installer.sh "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh" && \
    wget -O /bazel/LICENSE.txt "https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE" && \
    chmod +x /bazel/installer.sh && \
    /bazel/installer.sh && \
    rm -f /bazel/installer.sh
145 146

COPY bashrc /etc/bash.bashrc
A
Austin Anderson 已提交
147
RUN chmod a+rwx /etc/bash.bashrc
148

149
RUN python3 -m pip install --no-cache-dir jupyter matplotlib
A
Austin Anderson 已提交
150
# Pin ipykernel and nbformat; see https://github.com/ipython/ipykernel/issues/422
151
RUN python3 -m pip install --no-cache-dir jupyter_http_over_ws ipykernel==5.1.1 nbformat==4.4.0
Y
Yong Tang 已提交
152
RUN jupyter serverextension enable --py jupyter_http_over_ws
153

154
RUN mkdir -p /tf/tensorflow-tutorials && chmod -R a+rwx /tf/
A
Austin Anderson 已提交
155
RUN mkdir /.local && chmod a+rwx /.local
156
RUN apt-get install -y --no-install-recommends wget
T
Tom Carchrae 已提交
157 158
# some examples require git to fetch dependencies
RUN apt-get install -y --no-install-recommends git
159
WORKDIR /tf/tensorflow-tutorials
A
Austin Anderson 已提交
160 161 162 163 164 165
RUN wget https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/keras/classification.ipynb
RUN wget https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/keras/overfit_and_underfit.ipynb
RUN wget https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/keras/regression.ipynb
RUN wget https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/keras/save_and_load.ipynb
RUN wget https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/keras/text_classification.ipynb
RUN wget https://raw.githubusercontent.com/tensorflow/docs/master/site/en/tutorials/keras/text_classification_with_hub.ipynb
A
Austin Anderson 已提交
166
COPY readme-for-jupyter.md README.md
167 168
RUN apt-get autoremove -y && apt-get remove -y wget
WORKDIR /tf
169 170
EXPOSE 8888

171
RUN python3 -m ipykernel.kernelspec
172 173

CMD ["bash", "-c", "source /etc/bash.bashrc && jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --no-browser --allow-root"]