Skip to content

Commit acb0b39

Browse files
committed
Base kernel for CUDA 10.1 & Python 3.8
1 parent 511bc75 commit acb0b39

File tree

1 file changed

+71
-83
lines changed

1 file changed

+71
-83
lines changed

commons/Dockerfile.base.py38-cuda10.1

Lines changed: 71 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
FROM nvidia/cuda:10.1-devel-ubuntu18.04
1+
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
22

33
# TensorFlow version is tightly coupled to CUDA and cuDNN so it should be selected carefully
44
ARG CUDA=10.1
5-
ARG LIBNVINFER=6.0.1-1
6-
ARG LIBNVINFER_MAJOR_VERSION=6
5+
ARG LIBNVINFER=7.2.3-1
6+
ARG LIBNVINFER_MAJOR_VERSION=7
77
ARG CUDNN=7.6.5.32-1
8-
ENV CUDNN_VERSION 7.6.5.32
98
ENV NCCL=2.6.4
109
ENV NCCL_VERSION=2.6.4-1+cuda10.1
10+
ENV CUDNN_VERSION 7.6.5.32
1111
ENV MLNX_OFED_VERSION=5.1-2.3.7.1
1212
ENV MKL_VERSION=2020.3
1313
ENV MKL_BUILD=279
14-
ENV NUMPY_VERSION 1.18.5
15-
ENV SCIPY_VERSION 1.5.2
16-
17-
# Python 2.7 or 3.6 is supported by Ubuntu Bionic out of the box
14+
ENV NUMPY_VERSION 1.20.2
15+
ENV SCIPY_VERSION 1.6.2
16+
ENV OPENMPI 4.1.0
17+
# Python 3.8 is supported by Ubuntu Bionic out of the box
1818
ARG python=3.8
1919
ENV PYTHON_VERSION=${python}
2020

@@ -23,7 +23,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
2323
CPLUS_INCLUDE_PATH=/usr/include/gdal \
2424
C_INCLUDE_PATH=/usr/include/gdal \
2525
PYTHONUNBUFFERED=1 \
26-
LIBRARY_PATH="/usr/local/cuda/lib64/stubs:/opt/intel/compilers_and_libraries_2020.3.279/linux/mkl/lib/intel64" \
26+
LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
2727
_CUDA_COMPAT_PATH="/usr/local/cuda/compat" \
2828
LD_LIBRARY_PATH="/usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/compat/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64:/usr/include/x86_64-linux-gnu:/opt/intel/compilers_and_libraries_2020.3.279/linux/mkl/lib/intel64" \
2929
PATH="/usr/local/mpi/bin:/usr/local/ucx:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/bin/cmake/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/tensorrt/bin:/usr/local/src/lightgbm/LightGBM:/usr/local/bin/mecab" \
@@ -33,7 +33,6 @@ ENV DEBIAN_FRONTEND=noninteractive \
3333
# Set default shell to /bin/bash
3434
SHELL ["/bin/bash", "-cu"]
3535

36-
WORKDIR /tmp
3736
RUN rm -fr /var/lib/apt/lists/* && \
3837
apt-get update -y && \
3938
apt-get install -y --no-install-recommends software-properties-common wget && \
@@ -115,32 +114,35 @@ RUN rm -fr /var/lib/apt/lists/* && \
115114
echo "/opt/intel/ipp/lib/intel64" >> /etc/ls.so.conf && \
116115
echo "/opt/intel/lib/intel64" >> /etc/ls.so.conf && \
117116
echo "/opt/intel/mkl/lib/intel64" >> /etc/ls.so.conf && \
118-
find /usr/local/cuda-${CUDA}/lib64/ -type f -name 'lib*_static.a' -not -name 'libcudart_static.a' -delete && \
119-
ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
117+
find /usr/local/cuda-${CUDA}/lib64/ -type f -name 'lib*_static.a' -not -name 'libcudart_static.a' -delete
118+
119+
WORKDIR /tmp
120+
RUN curl -fsSL https://developer.download.nvidia.com/compute/redist/nccl/v2.6/nccl_2.6.4-1+cuda10.1_x86_64.txz -O && \
121+
tar --no-same-owner --keep-old-files --lzma -xvf nccl_${NCCL}-1+cuda10.1_x86_64.txz -C /usr/local/cuda/lib64/ --strip-components=2 --wildcards '*/lib/libnccl.so.*' && \
122+
tar --no-same-owner --keep-old-files --lzma -xvf nccl_${NCCL}-1+cuda10.1_x86_64.txz -C /usr/lib/pkgconfig/ --strip-components=3 --wildcards '*/lib/pkgconfig/*' && \
123+
rm nccl_${NCCL}-1+cuda10.1_x86_64.txz && \
124+
ldconfig
125+
126+
RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
120127
echo "/usr/local/cuda/lib64/stubs" > /etc/ld.so.conf.d/z-cuda-stubs.conf && \
121128
ldconfig
122129

123130
# Install CUDA-10.1 + cuDNN 7.6.5
124-
RUN apt-get update && \
125-
apt-get install -y --no-install-recommends \
126-
libcudnn7=$CUDNN_VERSION-1+cuda10.1 \
127-
libcudnn7-dev=$CUDNN_VERSION-1+cuda10.1 && \
128-
ln -s /usr/local/cuda-10.1 /usr/local/cuda && \
131+
RUN ln -s /usr/local/cuda-10.1 /usr/local/cuda && \
129132
ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5 /usr/local/cuda/lib64/libcudnn.so && \
130-
rm -rf /var/lib/apt/lists/* && \
131-
apt-mark hold libcudnn7 && \
132133
ldconfig
133134

134-
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
135+
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
135136
apt-get update -y && \
136-
apt-get install -y --no-install-recommends nodejs
137+
apt-get install -y nodejs
137138

138-
RUN apt-get update -y && \
139+
RUN apt-get update && \
139140
apt-get install -y --no-install-recommends \
140-
libnvinfer${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} \
141+
libnvinfer${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} \
141142
libnvinfer-dev=${LIBNVINFER}+cuda${CUDA} \
143+
libnvinfer-plugin7 \
142144
libnvinfer-plugin-dev=${LIBNVINFER}+cuda${CUDA} \
143-
libnvinfer-plugin${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} && \
145+
&& \
144146
apt-get clean && \
145147
rm -rf /var/lib/apt/lists/*
146148

@@ -149,26 +151,23 @@ RUN mkdir -p /etc/OpenCL/vendors && \
149151
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
150152

151153
# OFED
152-
ENV STAGE_DIR=/tmp
153-
RUN mkdir -p ${STAGE_DIR}
154-
ENV MLNX_OFED_VERSION=4.6-1.0.1.1
155-
RUN cd ${STAGE_DIR} && \
156-
wget -q -O - http://www.mellanox.com/downloads/ofed/MLNX_OFED-${MLNX_OFED_VERSION}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64.tgz | tar xzf -
157-
RUN cd ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64 && \
154+
WORKDIR /tmp
155+
RUN wget -q -O - https://www.mellanox.com/downloads/ofed/MLNX_OFED-5.1-2.3.7.1/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64.tgz | tar xzf - && \
156+
cd /tmp/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64 && \
158157
./mlnxofedinstall --user-space-only --without-fw-update --all -q && \
159-
cd ${STAGE_DIR} && \
160-
rm -rf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64*
158+
cd /tmp && \
159+
rm -rf /tmp/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64*
161160

162161
# nvidia-peer
163-
RUN mkdir -p ${STAGE_DIR} && \
164-
git clone https://github.com/Mellanox/nv_peer_memory.git ${STAGE_DIR}/nv_peer_memory && \
165-
cd ${STAGE_DIR}/nv_peer_memory && \
162+
WORKDIR /tmp
163+
RUN git clone https://github.com/Mellanox/nv_peer_memory.git /tmp/nv_peer_memory && \
164+
cd /tmp/nv_peer_memory && \
166165
./build_module.sh && \
167-
cd ${STAGE_DIR} && \
168-
tar xzf ${STAGE_DIR}/nvidia-peer-memory_1.1.orig.tar.gz && \
169-
cd ${STAGE_DIR}/nvidia-peer-memory-1.1 && \
166+
cd /tmp && \
167+
tar xzf /tmp/nvidia-peer-memory_1.1.orig.tar.gz && \
168+
cd /tmp/nvidia-peer-memory-1.1 && \
170169
dpkg-buildpackage -us -uc && \
171-
dpkg -i ${STAGE_DIR}/nvidia-peer-memory_1.1-0_all.deb
170+
dpkg -i /tmp/nvidia-peer-memory_1.1-0_all.deb
172171

173172
RUN wget https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-Linux-x86_64.sh \
174173
-q -O /tmp/cmake-install.sh && \
@@ -204,33 +203,16 @@ RUN rm /usr/bin/python /usr/bin/python3 && \
204203
WORKDIR /tmp
205204
RUN curl https://bootstrap.pypa.io/get-pip.py | python3 && \
206205
python3 -m pip install --no-cache-dir -U setuptools pip && \
207-
python3 -m pip install --no-cache-dir cython pybind11
208-
209-
RUN python3 -m pip install --no-cache-dir --upgrade -Iv \
210-
Cython==0.29.21 \
211-
tornado==6.0.4 \
212-
pystan==2.19.1.1 \
213-
pycairo==1.19.0 \
214-
python-language-server[all] \
215-
matplotlib==3.1.1
216-
217-
RUN cd /tmp && \
218-
git clone --recursive https://github.com/bodono/scs-python.git && \
219-
cd scs-python && \
220-
python3 setup.py install --scs --gpu
206+
python3 -m pip install --no-cache-dir cython pybind11 python-lsp-server
221207

222208
WORKDIR /tmp
209+
# OpenBlas
223210
RUN git clone -q --branch=master git://github.com/xianyi/OpenBLAS.git && \
224211
cd OpenBLAS && \
225-
make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=48 FC=gfortran NO_CBLAS=1 NO_LAPACK=1 NO_LAPACKE=1 && \
212+
make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=48 FC=gfortran && \
226213
make install
227-
228-
RUN git clone --recursive https://github.com/bodono/scs-python.git && \
229-
cd /tmp/scs-python && \
230-
python setup.py install --scs --gpu
231-
232-
RUN cd /tmp && \
233-
git clone --branch=v${NUMPY_VERSION} --depth=1 https://github.com/numpy/numpy.git numpy && \
214+
# Numpy
215+
RUN git clone --branch=v${NUMPY_VERSION} --depth=1 https://github.com/numpy/numpy.git numpy && \
234216
cd numpy && \
235217
git checkout -b v${NUMPY_VERSION} && \
236218
cp site.cfg.example site.cfg && \
@@ -241,7 +223,7 @@ RUN cd /tmp && \
241223
echo "lapack_libs =" >> site.cfg && \
242224
python3 setup.py bdist_wheel -d /tmp
243225

244-
# Install scipy
226+
# Scipy
245227
RUN cd /tmp && \
246228
git clone --branch=v${SCIPY_VERSION} --depth=1 https://github.com/scipy/scipy.git scipy && \
247229
cd scipy && \
@@ -252,32 +234,31 @@ RUN cd /tmp && \
252234
echo "library_dirs = /opt/intel/compilers_and_libraries_2020.3.279/linux/mkl/lib/intel64" >> site.cfg && \
253235
echo "mkl_libs = mkl_rt" >> site.cfg && \
254236
echo "lapack_libs =" >> site.cfg && \
255-
python3 -m pip install -U --no-cache-dir /tmp/numpy-1.18.5-cp36-cp36m-linux_x86_64.whl && \
237+
python3 -m pip install -U --no-cache-dir /tmp/numpy-*.whl && \
256238
python3 setup.py install
257-
258-
259-
RUN python3 -m pip install pip --no-cache-dir \
260-
Cartopy==0.18.0 \
261-
notebook==6.0.3
262-
263-
WORKDIR /tmp
264-
COPY ./requirements.py38.txt /tmp
265-
RUN python3 -m pip install --no-cache-dir -r requirements.py38.txt && \
266-
rm -f /tmp/*.whl /tmp/requirements.py38.txt
239+
RUN cd /tmp && \
240+
git clone --recursive https://github.com/bodono/scs-python.git && \
241+
cd scs-python && \
242+
python3 setup.py install --scs --gpu
267243

268244
# install NLP packages *mecab-ko & khai*
269-
WORKDIR /tmp
270-
RUN curl -LO https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz && \
245+
RUN apt-get update && \
246+
apt-get install -y \
247+
openjdk-8-jdk \
248+
automake \
249+
&& \
250+
cd /tmp && \
251+
curl -LO https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz && \
271252
tar zxfv mecab-0.996-ko-0.9.2.tar.gz && \
272253
cd mecab-0.996-ko-0.9.2 && \
273254
./configure && \
274255
make -j$(nproc) && \
275256
make check && \
276257
make install
277-
278-
# Install mecab-ko-dic
279-
WORKDIR /tmp
280-
RUN curl -LO https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz && \
258+
RUN echo "Install mecab-ko-dic" && \
259+
cd /tmp && \
260+
ldconfig && \
261+
curl -LO https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz && \
281262
tar -zxvf mecab-ko-dic-2.1.1-20180720.tar.gz && \
282263
cd mecab-ko-dic-2.1.1-20180720 && \
283264
./autogen.sh && \
@@ -289,6 +270,11 @@ RUN curl -LO https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2
289270
git clone https://bitbucket.org/eunjeon/mecab-python-0.996.git && \
290271
python3 -m pip install /tmp/mecab-python-0.996
291272

273+
WORKDIR /tmp
274+
COPY ./requirements.py38.txt /tmp
275+
RUN python3 -m pip install --no-cache-dir -r requirements.py38.txt && \
276+
rm -f /tmp/*.whl /tmp/requirements.py38.txt
277+
292278
# OpenCV
293279
RUN ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h && \
294280
apt-get install -y \
@@ -319,7 +305,7 @@ RUN ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h && \
319305
rm -rf /var/lib/apt/lists/
320306

321307
WORKDIR /tmp
322-
ENV OPENCV_VERSION="4.5.1"
308+
ENV OPENCV_VERSION="4.5.2"
323309
RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
324310
wget -O opencv-contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \
325311
unzip ${OPENCV_VERSION}.zip && \
@@ -332,7 +318,7 @@ RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
332318
-D BUILD_opencv_java=OFF \
333319
-D WITH_CUDA=ON \
334320
-D CUDA_NVCC_FLAGS=--expt-relaxed-constexpr \
335-
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.1 \
321+
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.1 \
336322
-D ENABLE_FAST_MATH=1 \
337323
-D CUDA_FAST_MATH=1 \
338324
-D WITH_CUBLAS=1 \
@@ -344,7 +330,7 @@ RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
344330
-D WITH_V4L=ON \
345331
-D BUILD_TESTS=OFF \
346332
-D BUILD_PERF_TESTS=OFF \
347-
-D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.5.1/modules" \
333+
-D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.5.2/modules" \
348334
-D CMAKE_BUILD_TYPE=RELEASE \
349335
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
350336
-D PYTHON_EXECUTABLE=$(which python3) \
@@ -369,7 +355,7 @@ RUN cd /usr/local/src && mkdir lightgbm && cd lightgbm && \
369355
git clone --recursive --branch stable --depth 1 https://github.com/microsoft/LightGBM && \
370356
cd LightGBM && mkdir build && cd build && \
371357
cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ .. && \
372-
make OPENCL_HEADERS=/usr/local/cuda-11.1/targets/x86_64-linux/include LIBOPENCL=/usr/local/cuda-11.1/targets/x86_64-linux/lib -j$(nproc) && \
358+
make OPENCL_HEADERS=/usr/local/cuda-10.1/targets/x86_64-linux/include LIBOPENCL=/usr/local/cuda-10.1/targets/x86_64-linux/lib -j$(nproc) && \
373359
cd /usr/local/src/lightgbm/LightGBM/python-package && \
374360
python3 setup.py install --precompile
375361

@@ -427,6 +413,7 @@ RUN curl -fL https://github.com/cdr/code-server/releases/download/v3.9.2/code-se
427413
mv /usr/local/lib/code-server-3.9.2-linux-amd64 /usr/local/lib/code-server-3.9.2 && \
428414
ln -s /usr/local/lib/code-server-3.9.2/bin/code-server /usr/local/bin/code-server
429415

416+
# Install Jupyterlab extensions
430417
RUN jupyter nbextensions_configurator enable && \
431418
jupyter contrib nbextension install && \
432419
jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
@@ -444,6 +431,7 @@ RUN jupyter nbextensions_configurator enable && \
444431

445432
# Clean up
446433
RUN apt autoclean && \
434+
ln -s /usr/local/cuda-10.1/targets/x86_64-linux/lib/libcusolver.so.11 /usr/local/cuda-10.1/targets/x86_64-linux/lib/libcusolver.so.10 && \
447435
sed -i 's/source \/usr\/local\/nvm\/nvm.sh//' /etc/bash.bashrc && \
448436
ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color && \
449437
rm -rf /var/lib/apt/lists/* && \

0 commit comments

Comments
 (0)