forked from flashlight/flashlight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-CPU-Base
164 lines (149 loc) · 6.69 KB
/
Dockerfile-CPU-Base
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
# ==================================================================
# module list
# ------------------------------------------------------------------
# Ubuntu 20.04
# OpenMPI latest (apt)
# cmake 3.16.3 (apt)
# MKL 2020.4-912 (apt)
# arrayfire 3.7.3 (git, CPU backend)
# libsndfile latest (apt)
# oneDNN v2.0 (git)
# Gloo 1da2117 (git)
# FFTW latest (apt)
# KenLM 0c4dd4e (git)
# GLOG latest (apt)
# gflags latest (apt)
# python3 latest (apt)
# ==================================================================
#############################################################################
# APT IMAGE + CMAKE #
#############################################################################
FROM ubuntu:20.04 as cpu_base_builder
ENV APT_INSTALL="apt-get install -y --no-install-recommends"
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive $APT_INSTALL \
build-essential \
ca-certificates \
wget \
git \
g++ \
cmake \
# for MKL
apt-transport-https gpg-agent gnupg2 \
# for kenlm
libboost-thread-dev libboost-test-dev libboost-system-dev libboost-program-options-dev \
# for arrayfire CPU backend
libboost-stacktrace-dev \
# OpenBLAS
libopenblas-dev liblapacke-dev \
# ATLAS
libatlas3-base libatlas-base-dev liblapacke-dev \
# FFTW
libfftw3-dev \
# ssh for OpenMPI
openssh-server openssh-client \
# for OpenMPI
libopenmpi-dev openmpi-bin \
# for kenlm
zlib1g-dev libbz2-dev liblzma-dev && \
# ==================================================================
# clean up everything
# ------------------------------------------------------------------
apt-get clean && \
apt-get -y autoremove && \
rm -rf /var/lib/apt/lists/*
#############################################################################
# DEPS IMAGES #
#############################################################################
FROM cpu_base_builder as cpu_arrayfire
# ==================================================================
# arrayfire with CPU backend https://github.com/arrayfire/arrayfire/wiki/
# ------------------------------------------------------------------
RUN cd /tmp && git clone --branch v3.7.3 --depth 1 --recursive --shallow-submodules https://github.com/arrayfire/arrayfire.git && \
mkdir -p arrayfire/build && cd arrayfire/build && \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/arrayfire \
-DAF_BUILD_CPU=ON \
-DAF_BUILD_CUDA=OFF \
-DAF_BUILD_OPENCL=OFF \
-DAF_BUILD_EXAMPLES=OFF \
-DAF_WITH_IMAGEIO=OFF \
-DBUILD_TESTING=OFF \
-DAF_BUILD_DOCS=OFF && \
make install -j$(nproc)
FROM cpu_base_builder as cpu_onednn
# ==================================================================
# oneDNN https://github.com/oneapi-src/oneDNN
# ------------------------------------------------------------------
RUN cd /tmp && git clone --branch v2.0 --depth 1 https://github.com/oneapi-src/onednn.git && \
mkdir -p onednn/build && cd onednn/build && \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/onednn \
-DDNNL_BUILD_EXAMPLES=OFF && \
make install -j$(nproc)
FROM cpu_base_builder as cpu_gloo
# ==================================================================
# Gloo https://github.com/facebookincubator/gloo.git
# ------------------------------------------------------------------
RUN cd /tmp && git clone https://github.com/facebookincubator/gloo.git && \
cd gloo && git checkout 1da2117 && mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/gloo \
-DUSE_MPI=ON && \
make install -j$(nproc)
FROM cpu_base_builder as cpu_kenlm
# ==================================================================
# KenLM https://github.com/kpu/kenlm
# ------------------------------------------------------------------
RUN cd /tmp && git clone https://github.com/kpu/kenlm.git && \
cd kenlm && git checkout 0c4dd4e && \
mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/kenlm \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON && \
make install -j$(nproc)
#############################################################################
# FINAL IMAGE #
#############################################################################
FROM cpu_base_builder as cpu_final
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive $APT_INSTALL \
vim \
emacs \
nano \
htop \
# libsndfile
libsndfile1-dev \
# gflags
libgflags-dev libgflags2.2 \
# for glog
libgoogle-glog-dev libgoogle-glog0v5 \
# python sox
sox libsox-dev python3-dev python3-pip python3-distutils && \
# python (for bindings and preprocessing)
python3 -m pip --no-cache-dir install --upgrade setuptools numpy sox tqdm && \
# ==================================================================
# clean up everything
# ------------------------------------------------------------------
apt-get clean && \
apt-get -y autoremove && \
rm -rf /var/lib/apt/lists/*
# ==================================================================
# MKL https://software.intel.com/en-us/mkl
# ------------------------------------------------------------------
RUN cd /tmp && wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list' && \
apt-get update && DEBIAN_FRONTEND=noninteractive $APT_INSTALL intel-mkl-64bit-2020.4-912 && \
# ==================================================================
# clean up everything
# ------------------------------------------------------------------
apt-get clean && \
apt-get -y autoremove && \
rm -rf /var/lib/apt/lists/* /tmp/*
COPY --from=cpu_arrayfire /opt/arrayfire /opt/arrayfire
COPY --from=cpu_onednn /opt/onednn /opt/onednn
COPY --from=cpu_gloo /opt/gloo /opt/gloo
COPY --from=cpu_kenlm /opt/kenlm /opt/kenlm
ENV MKLROOT="/opt/intel/mkl"
ENV KENLM_ROOT=/opt/kenlm