1
+ FROM lablup/common-base:20.08-py36-cuda11
2
+
3
+ ARG TF_BUILD_VERSION=v1.15.3+nv20.07
4
+ # Install the most recent bazel release.
5
+ ENV BAZEL_VERSION 0.26.1
6
+
7
+ # Set up Bazel.
8
+
9
+ # Running bazel inside a `docker build` command causes trouble, cf:
10
+ # https://github.com/bazelbuild/bazel/issues/134
11
+ # The easiest solution is to set up a bazelrc file forcing --batch.
12
+ RUN echo "startup --batch" >>/etc/bazel.bazelrc
13
+ # Similarly, we need to workaround sandboxing issues:
14
+ # https://github.com/bazelbuild/bazel/issues/418
15
+ RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
16
+ >>/etc/bazel.bazelrc
17
+
18
+ WORKDIR /
19
+ RUN mkdir /bazel && \
20
+ cd /bazel && \
21
+ 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 && \
22
+ 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 && \
23
+ chmod +x bazel-*.sh && \
24
+ ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
25
+ cd / && \
26
+ rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
27
+
28
+ # Download and build TensorFlow.
29
+ WORKDIR /tensorflow
30
+
31
+ # Download and build TensorFlow.
32
+ # Enable checking out both tags and branches
33
+ RUN export TAG_PREFIX="v" && \
34
+ echo ${TF_BUILD_VERSION} | grep -q ^${TAG_PREFIX}; \
35
+ if [ $? -eq 0 ]; then \
36
+ git clone --depth=1 https://github.com/nvidia/tensorflow.git . && \
37
+ git fetch --tags && \
38
+ git checkout ${TF_BUILD_VERSION}; \
39
+ else \
40
+ git clone --depth=1 --branch=${TF_BUILD_VERSION} https://github.com/nvidida/tensorflow.git . ; \
41
+ fi
42
+
43
+ RUN yes "" | python3 configure.py
44
+ RUN cp .bazelrc /root/.bazelrc
45
+
46
+ ENV CI_BUILD_PYTHON ${PYTHON}
47
+ ENV WHL_DIR=/tmp/pip3
48
+ # Set bazel build parameters in .bazelrc in parameterized_docker_build.sh
49
+ # Use --copt=-march values to get optimized builds appropriate for the hardware
50
+ # platform of your choice.
51
+ # For ivy-bridge or sandy-bridge
52
+ # --copt=-march="avx" \
53
+ # For haswell, broadwell, or skylake
54
+ # --copt=-march="avx2" \
55
+ COPY .bazelrc /root/.mkl.bazelrc
56
+ RUN echo "import /root/.mkl.bazelrc" >>/root/.bazelrc
57
+
58
+ ENV TF_NEED_TENSORRT=1
59
+ ENV TF_CUDA_COMPUTE_CAPABILITIES sm_37,sm_52,sm_60,sm_61,sm_70,sm_75,compute_70,compute_75,compute_80
60
+
61
+ RUN tensorflow/tools/ci_build/builds/configured CPU \
62
+ bazel --bazelrc=/root/.bazelrc build \
63
+ -c opt \
64
+ --copt=-msse4.1 \
65
+ --copt=-msse4.2 \
66
+ --copt=-mavx \
67
+ --copt=-mavx2 \
68
+ --copt=-mfma \
69
+ --copt=-mfpmath=both \
70
+ --copt=-O3 \
71
+ --copt=-Wformat \
72
+ --copt=-Wformat-security \
73
+ --copt=-fstack-protector \
74
+ --copt=-fPIC \
75
+ --copt=-fpic \
76
+ --config=opt \
77
+ --config=cuda \
78
+ --config=mkl \
79
+ --config=monolithic \
80
+ --config=gdr \
81
+ --config=verbs \
82
+ # --config=ngraph \
83
+ --config=numa \
84
+ --config=v1 \
85
+ --linkopt=-znoexecstack \
86
+ --linkopt=-zrelro \
87
+ --linkopt=-znow \
88
+ --linkopt=-fstack-protector \
89
+ --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \
90
+ -k //tensorflow/tools/pip_package:build_pip_package && \
91
+ bazel-bin/tensorflow/tools/pip_package/build_pip_package "${WHL_DIR}" && \
92
+ python3 -m pip --no-cache-dir install --upgrade "${WHL_DIR}" /tensorflow-*.whl
93
+ RUN python3 -m pip --no-cache-dir install \
94
+ tensorboard==1.15 && \
95
+ rm -rf /root/.cache
96
+ # Clean up Bazel cache when done.
97
+
98
+ # Install Horovod, temporarily using CUDA stubs
99
+ RUN HOROVOD_WITH_TENSORFLOW=1 HOROVOD_WITHOUT_PYTORCH=1 HOROVOD_WITHOUT_MXNET=1 \
100
+ pip install --no-cache-dir horovod==0.19.5 && \
101
+ ldconfig
102
+
103
+ RUN python3 -m pip install --no-cache-dir \
104
+ mpi4py==3.0.3 \
105
+ nni==1.6 \
106
+ scikit-nni==0.2.1
107
+
108
+ # Install ipython kernelspec
109
+ Run python3 -m ipykernel install --display-name "TensorFlow 1.15 on Python 3.6 (CPU, MKL)" && \
110
+ cat /usr/local/share/jupyter/kernels/python3/kernel.json
111
+
112
+ # Backend.AI specifics
113
+ LABEL ai.backend.kernelspec="1" \
114
+ ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
115
+ ai.backend.features="batch query uid-match user-input" \
116
+ ai.backend.base-distro="ubuntu16.04" \
117
+ ai.backend.resource.min.cpu="1" \
118
+ ai.backend.resource.min.mem="1g" \
119
+ ai.backend.resource.min.cuda.device=0 \
120
+ ai.backend.resource.min.cuda.shares=0 \
121
+ ai.backend.runtime-type="python" \
122
+ ai.backend.runtime-path="/usr/bin/python3" \
123
+ ai.backend.service-ports="ipython:pty:3000,jupyter:http:8080,jupyterlab:http:8090,vscode:http:8180,tensorboard:http:6006"
124
+
125
+ WORKDIR /home/work
126
+ # vim: ft=dockerfile
0 commit comments