forked from flashlight/flashlight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-CUDA-Base
144 lines (130 loc) · 5.9 KB
/
Dockerfile-CUDA-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
# ==================================================================
# module list
# ------------------------------------------------------------------
# Ubuntu 20.04
# OpenMPI latest (apt)
# CUDA 11.1
# CuDNN 8-dev
# cmake 3.16.3 (apt)
# MKL 2020.4-912 (apt)
# arrayfire 3.7.3 (git, CUDA backend)
# libsndfile latest (apt)
# FFTW latest (apt)
# KenLM 0c4dd4e (git)
# GLOG latest (apt)
# gflags latest (apt)
# python3 latest (apt)
# ==================================================================
FROM nvidia/cuda:11.1-cudnn8-devel-ubuntu20.04 as cuda_base_builder
# If the driver is not found (during docker build) the cuda driver api need to be linked against the
# libcuda.so stub located in the lib[64]/stubs directory
RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/lib/libcuda.so.1
ENV APT_INSTALL="apt-get install -y --no-install-recommends"
ENV DEBIAN_FRONTEND=noninteractive
RUN rm -rf /var/lib/apt/lists/* \
/etc/apt/sources.list.d/cuda.list \
/etc/apt/sources.list.d/nvidia-ml.list && \
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
libboost-stacktrace-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 cuda_base_builder as cuda_arrayfire
# ==================================================================
# arrayfire with CUDA backend https://github.com/arrayfire/arrayfire/wiki/Build-Instructions-for-Linux#cuda-backend-dependencies
# ------------------------------------------------------------------
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 && \
CXXFLAGS=-DOS_LNX cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/arrayfire \
-DAF_BUILD_CUDA=ON \
-DAF_BUILD_CPU=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 cuda_base_builder as cuda_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 cuda_base_builder as cuda_final
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive $APT_INSTALL \
vim \
emacs \
nano \
htop \
# nccl: for flashlight
libnccl2 libnccl-dev \
# libsndfile
libsndfile1-dev \
# for Intel's Math Kernel Library (MKL)
cpio \
# 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=cuda_arrayfire /opt/arrayfire /opt/arrayfire
COPY --from=cuda_kenlm /opt/kenlm /opt/kenlm
ENV KENLM_ROOT=/opt/kenlm