-
Notifications
You must be signed in to change notification settings - Fork 95
/
Dockerfile-build
229 lines (182 loc) · 7.4 KB
/
Dockerfile-build
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
ARG docker_name
FROM $docker_name
MAINTAINER H2o.ai <ops@h2o.ai>
#
# Env variables for CUDA. Necessary because certain systems don't support nvidia-docker so we should use plain docker as much as possible.
#
ENV HOME=/root
ENV CUDA_HOME=/usr/local/cuda
ENV CUDADIR=/usr/local/cuda/include/
ENV PATH=/usr/local/cuda/bin:$PATH
ENV LD_LIBRARY_PATH_CUDA=$CUDA_HOME/lib64/:$CUDA_HOME/lib/:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
ENV LD_LIBRARY_PATH_BUILD=/lib64:/usr/local/lib64:/home/$USER/lib/
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH_CUDA:$LD_LIBRARY_PATH_BUILD:$LD_LIBRARY_PATH
#
# Env variables used by the codebase.
#
ENV OMP_NUM_THREADS=32
ENV MKL_NUM_THREADS=32
ENV VECLIB_MAXIMUM_THREADS=32
ENV GIT_VERSION=2.17.0
#
# Install necessary libraries and dependencies
#
RUN yum install -y epel-release
# RUN yum update -y
RUN yum install centos-release-scl-rh -y
# Setup gcc etc.
RUN yum install -y gcc gcc-c++ libgcc libstdc++ libgomp glibc
# Git & gcc requirements
RUN yum install -y libcurl-devel zlib-devel asciidoc xmlto wget make autoconf gettext gmp-devel mpfr-devel libmpc-devel
RUN yum install -y devtoolset-7
# Compile from source because yum's latest version is 1.8.3
# --depth for submodule update which we use was added in 1.8.4
RUN \
wget https://www.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.xz && \
tar xf git-${GIT_VERSION}.tar.xz && \
cd git-${GIT_VERSION} && \
make configure && \
./configure --prefix=/usr && \
make all && \
make install;
#H2O4GPU requirements
RUN yum install -y \
ncurses-devel \
bzip2 \
which \
axel \
openssl-devel \
libpng-devel \
freetype-devel \
blas-devel \
epel-release \
zeromq-devel \
openblas-devel \
libffi-devel
RUN \
git clone https://github.com/NVIDIA/nccl.git && \
cd nccl && \
git checkout tags/v2.4.7-1 && \
scl enable devtoolset-7 'make CUDA8_GENCODE="-gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_61,code=sm_61" -j src.build';
# cmake 3.17.1 looks incompatible with CUDA
RUN wget https://github.com/Kitware/CMake/releases/download/v3.16.8/cmake-3.16.8.tar.gz && \
tar -zxvf cmake-3.16.8.tar.gz && \
cd cmake-3.16.8 && \
./bootstrap && \
make -j`nproc` && \
make install
RUN mkdir -p /opt/h2oai/h2o4gpu
RUN wget https://s3.amazonaws.com/artifacts.h2o.ai/releases/ai/h2o/dai-thirdparty-deps/1.0-master-22/`arch`-centos7/llvm.tar.bz2 && \
tar xvf llvm.tar.bz2 && \
cp -r llvm/* /opt/h2oai/h2o4gpu/ && \
rm -rf llvm*
ENV LLVM4=/opt/h2oai/h2o4gpu
ENV PATH=$LLVM4/bin:$PATH
ENV LD_LIBRARY_PATH=$LLVM4/lib:$LD_LIBRARY_PATH
ENV LLVM_CONFIG=$LLVM4/bin/llvm-config
#
# Library versions
#
ARG python_version
ENV MINICONDA_VERSION=4.8.3
ENV SWIG_VERSION=3.0.12
# conda
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py38_${MINICONDA_VERSION}-Linux-`arch`.sh && \
bash Miniconda3-py38_${MINICONDA_VERSION}-Linux-`arch`.sh -b -p /opt/h2oai/h2o4gpu/python && \
/opt/h2oai/h2o4gpu/python/bin/conda install -y python=${python_version} conda-build pip && \
/opt/h2oai/h2o4gpu/python/bin/conda update conda-build
ENV PATH=/opt/h2oai/h2o4gpu/python/bin:$PATH
ENV PATH=/usr/local/bin:$PATH
#
# Symlinks
#
# AR for conda
RUN ln /usr/bin/ar $LLVM4/bin/`arch`-conda_cos6-linux-gnu-ar
# Symlinks for Python libs used by SWIG in CMake - it does not recognize Miniconda paths otherwise
RUN \
mkdir -p /usr/lib64/ && \
ln -sf /opt/h2oai/h2o4gpu/python/lib/libpython* /usr/lib64/ && \
mkdir -p /usr/include/python${python_version}m && \
ln -s /opt/h2oai/h2o4gpu/python/include/python${python_version}m/* /usr/include/python${python_version}m
# Yumming openblas puts some files in a not-so-standard locations
RUN ln -s /usr/include/openblas/* /usr/local/include/
# Symlinks for NVML
RUN \
mkdir -p /usr/lib64/nvidia/ && \
ln -s /usr/local/cuda-`nvcc --version | tail -n 1 | cut -f 5 -d' ' | cut -f 1 -d ','`/targets/`arch`-linux/lib/stubs/libnvidia-ml.so /usr/lib64/nvidia/libnvidia-ml.so
#
# Builds from source due to too old versions in yum
#
WORKDIR $HOME
# SWIG
RUN \
wget https://0xdata-public.s3.amazonaws.com/swig/swig-${SWIG_VERSION}.tar.gz && \
tar -zxvf swig-${SWIG_VERSION}.tar.gz && \
cd swig-${SWIG_VERSION} && \
./configure --prefix=/usr && \
make -j $(nproc) && \
make install && \
cd $HOME && \
rm -rf swig-3*
#
# PPC64 specific - certain libs/whl don't support PPC64LE
#
# Arrow
# Need to enable c99 manually https://github.com/numpy/numpy/issues/14147
RUN bash -c 'if [ `arch` = "ppc64le" ]; then \
git clone https://github.com/apache/arrow.git && \
cd $HOME/arrow/cpp && \
git checkout tags/apache-arrow-0.17.1 && \
yum install -y boost-devel && \
CFLAGS=-std=c99 pip install numpy==1.19.2 cython==0.29.14 scipy==1.5.2 && \
cmake -DARROW_CXXFLAGS="-lutil" -DARROW_PYTHON=on && make -j && make install && \
cd $HOME/arrow/python && \
ARROW_HOME=/usr/local python setup.py install && \
yum install -y libjpeg-devel;\
fi'
#
# Install Python requirements
#
RUN echo ${python_version}
RUN pip install -U pip==23.3.2
RUN pip install numpy==1.23.5 scipy==1.10.1 setuptools==58.5.3
COPY src/interface_py/requirements_buildonly.txt requirements_buildonly.txt
RUN pip install -r requirements_buildonly.txt
RUN mkdir -p /etc/OpenCL/vendors && \
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
RUN (localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 || true)
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
# See https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#with-gpu-support for details
# https://github.com/Microsoft/LightGBM/pull/929/files
# Could compile with these as well: -DBOOST_COMPUTE_USE_OFFLINE_CACHE=OFF -DBOOST_COMPUTE_THREAD_SAFE=ON
RUN \
export CUDA_HOME=/usr/local/cuda/ && \
yum install -y opencl-headers icu libicu-devel bzip2 bzip2-devel zlib-devel python-devel && \
wget https://github.com/boostorg/boost/releases/download/boost-1.82.0/boost-1.82.0.tar.gz && \
tar -zxvf boost-1.82.0.tar.gz && \
cd boost-1.82.0 && \
export PYTHONPATH=/opt/h2oai/h2o4gpu/python/ && \
./bootstrap.sh --prefix=/opt/boost/ --with-python=python3 && \
export CPPFLAGS="-I/opt/h2oai/h2o4gpu/python/include/python${python_version}/ -fPIC" && \
export C_INCLUDE_PATH="/opt/h2oai/h2o4gpu/python/include/python${python_version}/" && export CPLUS_INCLUDE_PATH="/opt/h2oai/h2o4gpu/python/include/python${python_version}m/" && \
./b2 link=static -a -d0 install --prefix=/opt/boost/ --with=all -j 20 cxxflags="-fPIC -I /opt/h2oai/h2o4gpu/python/include/python${python_version}/" && \
cd /usr/include && rm -rf boost && ln -s /opt/boost/include/boost . && \
cd /usr/lib64/ && rm -rf libboost* && cp -a /opt/boost/lib/* . && \
cd /
# yum install -y boost boost-devel boost-system boost-filesystem boost-thread
ENV LD_LIBRARY_PATH=/opt/boost/lib/:$LD_LIBRARY_PATH
RUN chmod -R o+rwx /opt/h2oai/h2o4gpu/python
RUN chmod -R o+rwx /root
RUN yum install -y hdf5-devel
RUN bash -c 'if [ `arch` == "ppc64le" ]; then \
yum install -y ocl-icd; \
fi'
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/nvidia
ENV CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
WORKDIR $HOME
ENV GIT_AUTHOR_NAME="anonymous"
ENV GIT_AUTHOR_EMAIL="anonymous@h2o.ai"
ENV GIT_COMMITTER_NAME="anonymous"
ENV GIT_COMMITTER_EMAIL="anonymous@h2o.ai"
ENV EMAIL="anonymous@h2o.ai"