-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
230 lines (202 loc) · 8.05 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# Build this image: docker build -t halo:[version] .
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
# Redeclare the argument
ARG BASE_IMAGE
ENV \
CUDNN_VERSION=7.6.0.64-1+cuda10.0 \
TENSORRT_VERSION=7.0.0-1+cuda10.0 \
CMAKE_VERSION=3.14.5 \
VALGRIND_VERSION=3.13.0 \
GCC_VERSION=7 \
LLVM_VERSION=9 \
BINUTILS_VERSION=2.32
ARG python=3.7.0
ENV PYTHON_VERSION=${python}
# To access the host directory
RUN mkdir /host
RUN apt-get update && apt-get -y --no-install-recommends install software-properties-common apt-utils wget && rm -fr /var/lib/apt/lists/*
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
apt-transport-https \
build-essential \
autoconf \
automake \
libtool \
cgdb \
ccache \
nasm \
libc6-dbg \
qemu-user \
git-core \
ca-certificates \
gdb \
vim \
curl \
libcurl4-openssl-dev \
cpio \
sudo \
pkg-config \
zip \
zlib1g-dev \
xterm \
unzip \
libpcre3 \
libpcre3-dev \
checkinstall \
yasm \
gfortran \
libpng-dev \
libjpeg8 \
libjpeg8-dev \
gpg-agent \
graphviz \
doxygen \
python3-setuptools \
python3-dev \
python3-pip \
openssh-client \
openssh-server \
g++-${GCC_VERSION} gcc-${GCC_VERSION} \
g++-5-aarch64-linux-gnu \
less \
scons \
git-lfs \
ninja-build \
libopencv-core-dev \
libopencv-highgui-dev \
libopencv-videoio-dev \
libmpc-dev \
libmpfr-dev \
libgmp-dev\
gawk \
imagemagick \
bison \
flex \
texinfo \
texlive \
texlive-latex-extra \
latex-cjk-all \
libglib2.0-dev \
libpixman-1-dev \
bc && \
apt-get clean && apt-get purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 60 --slave /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION} && \
update-alternatives --install /usr/bin/aarch64-linux-gnu-g++ aarch64-linux-gnu-g++ /usr/bin/aarch64-linux-gnu-g++-5 60 && \
update-alternatives --install /usr/bin/aarch64-linux-gnu-gcc aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-gnu-gcc-5 60 && \
update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 20 && \
update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.bfd" 10
SHELL ["/bin/bash", "-c"]
#update/install the CUDNN
RUN if [[ "${BASE_IMAGE}" =~ "nvidia" ]]; then echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list ; fi
RUN if [[ "${BASE_IMAGE}" =~ "nvidia" ]]; then echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list ; fi
RUN if [[ "${BASE_IMAGE}" =~ "nvidia" ]]; then wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub | apt-key add - ;fi
RUN if [[ "${BASE_IMAGE}" =~ "nvidia" ]]; then wget -qO - https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub | apt-key add -; fi
RUN if [[ "${BASE_IMAGE}" =~ "nvidia" ]]; then add-apt-repository -y ppa:ubuntu-toolchain-r/test ; fi
RUN if [[ "${BASE_IMAGE}" =~ "nvidia" ]]; then apt-get update -y && apt-get install -y --no-install-recommends --allow-change-held-packages --allow-downgrades \
libcudnn7=${CUDNN_VERSION} \
libcudnn7-dev=${CUDNN_VERSION} ; fi
# Install TensorRT
RUN if [[ "${BASE_IMAGE}" =~ "nvidia" ]]; then apt-get update -y && \
apt-get install -y --no-install-recommends --allow-change-held-packages \
libnvinfer7=${TENSORRT_VERSION} \
libnvinfer-dev=${TENSORRT_VERSION} \
libnvinfer-plugin7=${TENSORRT_VERSION} \
libnvonnxparsers7=${TENSORRT_VERSION} \
python3-libnvinfer-dev=${TENSORRT_VERSION} \
python3-libnvinfer=${TENSORRT_VERSION} \
libnvinfer-plugin-dev=${TENSORRT_VERSION} \
libnvparsers-dev=${TENSORRT_VERSION} \
libnvonnxparsers-dev=${TENSORRT_VERSION} \
libnvparsers7=${TENSORRT_VERSION} && \
apt-get clean && apt-get purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ; fi
# INSTALL LLVM
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-${LLVM_VERSION} main" && \
apt-get update && apt-get install -y --no-install-recommends \
clang-${LLVM_VERSION} \
clangd-${LLVM_VERSION} \
clang-tools-${LLVM_VERSION} \
clang-tidy-${LLVM_VERSION} \
clang-format-${LLVM_VERSION} && \
apt-get clean && apt-get purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#python
RUN pip3 install wheel numpy six jupyter enum34 mock h5py pillow
# Update binutils
RUN mkdir /tmp/binutils && \
cd /tmp/binutils && \
wget http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.gz && \
tar zxf binutils-${BINUTILS_VERSION}.tar.gz && \
cd binutils-${BINUTILS_VERSION} && \
./configure && \
make -j all && \
make install && \
rm -rf /tmp/binutils
# Install cmake
RUN mkdir /tmp/cmake && \
cd /tmp/cmake && \
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \
tar zxf cmake-${CMAKE_VERSION}.tar.gz && \
cd cmake-${CMAKE_VERSION} && \
./bootstrap --system-curl --parallel=48 && \
make -j all && \
make install && \
rm -rf /tmp/cmake
# Install valgrind
RUN mkdir /tmp/valgrind && \
cd /tmp/valgrind && \
wget ftp://sourceware.org/pub/valgrind/valgrind-${VALGRIND_VERSION}.tar.bz2 && \
tar jxf valgrind-${VALGRIND_VERSION}.tar.bz2 && \
cd valgrind-${VALGRIND_VERSION} && \
./configure && \
make -j all && \
make install && \
rm -rf /tmp/valgrind
# INSTALL Protobuf
RUN cd /tmp && \
git clone --depth=1 https://github.com/protocolbuffers/protobuf.git -b v3.9.1 && \
cd protobuf && \
./autogen.sh && ./configure && make -j && make install && \
rm -fr /tmp/protobuf && \
echo "/usr/local/lib" >> /etc/ld.so.conf
# INSTALL glog
RUN cd /tmp && \
git clone --depth=1 https://github.com/google/glog.git -b v0.4.0 && \
cd glog && \
cmake -H. -Bbuild -G "Unix Makefiles" && cmake --build build && \
cmake --build build --target install && ldconfig && \
rm -fr /tmp/glog
# Build & Install DNNL (MKLDNN)
RUN cd /tmp && git clone --depth=1 https://github.com/intel/mkl-dnn.git --branch v1.2-rc && \
cd /tmp/mkl-dnn && \
cmake -G Ninja -DDNNL_BUILD_EXAMPLES=OFF -DDNNL_BUILD_TESTS=OFF -DDNNL_ENABLE_PRIMITIVE_CACHE=ON -DCMAKE_INSTALL_PREFIX=/opt/dnnl && \
ninja install
# Install Eigen
RUN cd /tmp && wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.bz2 && \
tar jxvf eigen-3.3.7.tar.bz2 && mv eigen-3.3.7 /opt
# Install XNNPack
RUN cd /tmp && git clone https://github.com/google/XNNPACK.git && \
cd /tmp/XNNPACK && git checkout -b tmp 90db69f681ea9abd1ced813c17c00007f14ce58b && \
mkdir /tmp/xnn_build_static && cd /tmp/xnn_build_static && \
cmake -G Ninja ../XNNPACK -DXNNPACK_LIBRARY_TYPE=static -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DXNNPACK_BUILD_TESTS=OFF -DXNNPACK_BUILD_BENCHMARKS=OFF -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/XNNPACK && \
ninja install
# Install frameworks for model conversion
RUN pip3 install torch
RUN pip3 install tensorflow tf_slim scipy matplotlib
RUN mkdir -p /var/run/sshd
RUN sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config
# Allow OpenSSH to talk to containers without asking for confirmation
RUN echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config
# Set SSH with the deploy key
ENV SSHDIR /root/.ssh
RUN mkdir -p ${SSHDIR}
RUN echo "StrictHostKeyChecking no" > ${SSHDIR}/config
# Add PATH
RUN echo "PATH=\".:/usr/local/cuda/bin:\$PATH\"" >> /root/.profile
#Clean up
RUN apt clean && apt purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Start the ssh
ENTRYPOINT service ssh restart && ldconfig && bash