Skip to content

Commit 327aee1

Browse files
committed
Python COnda & CUDA10.1 based on Centos8
1 parent de72a24 commit 327aee1

File tree

1 file changed

+264
-0
lines changed

1 file changed

+264
-0
lines changed
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
FROM centos:8
2+
LABEL maintainer "Mario Cho <[email protected]>"
3+
4+
ENV DEBIAN_FRONTEND=noninteractive \
5+
MPLBACKEND=Svg \
6+
PYTHONUNBUFFERED=1 \
7+
LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
8+
_CUDA_COMPAT_PATH="/usr/local/cuda/compat" \
9+
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"\
10+
PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:/opt/conda/bin:/usr/local/sbin:/usr/bin/cmake/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/tensorrt/bin" \
11+
LANG=C.UTF-8
12+
13+
ENV CUDA_VER 10.1
14+
ENV CUDA_VERSION 10.1.243
15+
ENV CUDA_PKG_VERSION 10-1-$CUDA_VERSION-1
16+
ENV NCCL_VERSION 2.8.4
17+
ENV CUDNN_VERSION 7.6.5.32
18+
LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"
19+
20+
# nvidia-container-runtime
21+
ENV NVIDIA_VISIBLE_DEVICES all
22+
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
23+
ENV NVIDIA_REQUIRE_CUDA "cuda>=10.1 brand=tesla,driver>=396,driver<397 brand=tesla,driver>=410,driver<411 brand=tesla,driver>=418,driver<419"
24+
ENV CUDA_HOME /usr/local/cuda
25+
26+
RUN yum update -y && \
27+
yum install -y epel-release && \
28+
yum install -y https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm && \
29+
dnf -y install dnf-plugins-core && \
30+
yum install -y \
31+
atlas-devel \
32+
numactl-devel && \
33+
dnf -y --enablerepo=powertools install \
34+
alsa-lib \
35+
cairo \
36+
cairo-devel \
37+
gcc-c++ \
38+
giflib-devel \
39+
lapack-devel \
40+
libjpeg-turbo-devel \
41+
libtool \
42+
make \
43+
nano \
44+
numactl \
45+
numactl-libs \
46+
openblas-devel \
47+
openssh-server \
48+
pmix-devel \
49+
vim \
50+
openssh-clients \
51+
autoconf \
52+
automake \
53+
bc \
54+
ca-certificates \
55+
cmake \
56+
curl \
57+
ffmpeg \
58+
flac \
59+
gawk \
60+
gcc-gfortran \
61+
git \
62+
libsndfile-devel \
63+
openssl-devel \
64+
python3 \
65+
sox \
66+
subversion \
67+
unzip \
68+
wget \
69+
zip \
70+
zlib && \
71+
curl -sL https://rpm.nodesource.com/setup_14.x | bash - && \
72+
yum install -y nodejs
73+
74+
RUN NVIDIA_GPGKEY_SUM=d1be581509378368edeec8c1eb2958702feedf3bc3d17011adbf24efacce4ab5 && \
75+
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/7fa2af80.pub | sed '/^Version/d' > /etc/pki/rpm-gpg/RPM-GPG-KEY-NVIDIA && \
76+
echo "$NVIDIA_GPGKEY_SUM /etc/pki/rpm-gpg/RPM-GPG-KEY-NVIDIA" | sha256sum -c --strict -
77+
78+
COPY cuda.repo /etc/yum.repos.d/cuda.repo
79+
COPY nvidia-ml.repo /etc/yum.repos.d/nvidia-ml.repo
80+
#COPY NGC-DL-CONTAINER-LICENSE /
81+
82+
RUN yum upgrade -y && yum install -y \
83+
cuda-cudart-$CUDA_PKG_VERSION \
84+
cuda-compat-10-1 && \
85+
ln -s cuda-10.1 /usr/local/cuda && \
86+
echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
87+
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
88+
89+
90+
# setopt flag prevents yum from auto upgrading. See https://gitlab.com/nvidia/container-images/cuda/-/issues/88
91+
RUN yum install --setopt=obsoletes=0 -y \
92+
cuda-libraries-$CUDA_PKG_VERSION \
93+
cuda-nvtx-$CUDA_PKG_VERSION \
94+
cuda-npp-$CUDA_PKG_VERSION \
95+
libcublas10-10.2.1.243-1 \
96+
&& yum clean all \
97+
&& rm -rf /var/cache/yum/*
98+
99+
RUN yum install -y yum-plugin-versionlock && yum versionlock libcublas10
100+
101+
# setopt flag prevents yum from auto upgrading. See https://gitlab.com/nvidia/container-images/cuda/-/issues/88
102+
RUN yum install --setopt=obsoletes=0 -y \
103+
make \
104+
cuda-nvml-dev-$CUDA_PKG_VERSION \
105+
cuda-command-line-tools-$CUDA_PKG_VERSION \
106+
libcublas-devel-10.2.1.243-1 \
107+
cuda-cudart-dev-$CUDA_PKG_VERSION \
108+
cuda-libraries-dev-$CUDA_PKG_VERSION \
109+
cuda-minimal-build-$CUDA_PKG_VERSION \
110+
cuda-nvprof-$CUDA_PKG_VERSION \
111+
cuda-npp-dev-$CUDA_PKG_VERSION \
112+
&& yum clean all \
113+
&& rm -rf /var/cache/yum/*
114+
115+
RUN yum install -y yum-plugin-versionlock && yum versionlock libcublas10
116+
117+
RUN yum install -y xz && NCCL_DOWNLOAD_SUM=bcff1cf98e4b24d7ca189577a9d909980d8df88075223d70dc4638e428c53f84 && \
118+
curl -fsSL https://developer.download.nvidia.com/compute/redist/nccl/v2.8/nccl_2.8.4-1+cuda10.1_x86_64.txz -O && \
119+
echo "$NCCL_DOWNLOAD_SUM nccl_2.8.4-1+cuda10.1_x86_64.txz" | sha256sum -c - && \
120+
unxz nccl_2.8.4-1+cuda10.1_x86_64.txz && \
121+
tar --no-same-owner --keep-old-files -xvf nccl_2.8.4-1+cuda10.1_x86_64.tar -C /usr/local/cuda/include/ --strip-components=2 --wildcards '*/include/*' && \
122+
tar --no-same-owner --keep-old-files -xvf nccl_2.8.4-1+cuda10.1_x86_64.tar -C /usr/local/cuda/lib64/ --strip-components=2 --wildcards '*/lib/libnccl.so' && \
123+
rm -f nccl_2.8.4-1+cuda10.1_x86_64.tar && \
124+
ldconfig
125+
126+
127+
# cuDNN license: https://developer.nvidia.com/cudnn/license_agreement
128+
RUN CUDNN_DOWNLOAD_SUM=7eaec8039a2c30ab0bc758d303588767693def6bf49b22485a2c00bf2e136cb3 && \
129+
curl -fsSL http://developer.download.nvidia.com/compute/redist/cudnn/v7.6.5/cudnn-10.1-linux-x64-v7.6.5.32.tgz -O && \
130+
echo "$CUDNN_DOWNLOAD_SUM cudnn-10.1-linux-x64-v7.6.5.32.tgz" | sha256sum -c - && \
131+
gunzip cudnn-10.1-linux-x64-v7.6.5.32.tgz && \
132+
tar --no-same-owner -xf cudnn-10.1-linux-x64-v7.6.5.32.tar -C /usr/local --wildcards 'cuda/lib64/libcudnn.so.*' && \
133+
rm cudnn-10.1-linux-x64-v7.6.5.32.tar && \
134+
ldconfig
135+
136+
137+
# Install miniconda 3.8
138+
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py38_4.9.2-Linux-x86_64.sh -O miniconda.sh && \
139+
mkdir -p /opt && \
140+
sh miniconda.sh -b -p /opt/conda && \
141+
rm miniconda.sh && \
142+
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
143+
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
144+
echo "conda activate base" >> ~/.bashrc && \
145+
find /opt/conda/ -follow -type f -name '*.a' -delete && \
146+
find /opt/conda/ -follow -type f -name '*.js.map' -delete && \
147+
/opt/conda/bin/conda clean -afy
148+
149+
# Install OpenBlas
150+
WORKDIR /tmp
151+
RUN git clone -q --branch=master git://github.com/xianyi/OpenBLAS.git && \
152+
cd OpenBLAS && \
153+
make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=48 FC=gfortran && \
154+
make install
155+
156+
# Install Open UCX
157+
WORKDIR /tmp
158+
RUN wget https://github.com/openucx/ucx/archive/v1.9.0.tar.gz && \
159+
tar xvf v1.9.0.tar.gz && \
160+
cd ucx-1.9.0 && \
161+
bash ./autogen.sh && \
162+
mkdir build && \
163+
cd build && \
164+
../configure --prefix=/usr/local/ucx && \
165+
make -j$(nproc) && \
166+
make install
167+
168+
# Install Open MPI
169+
RUN mkdir /tmp/openmpi && \
170+
cd /tmp/openmpi && \
171+
wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.0.tar.gz && \
172+
tar zxf openmpi-4.1.0.tar.gz && \
173+
cd openmpi-4.1.0 && \
174+
./configure --enable-orterun-prefix-by-default --with-cuda --with-ucx=/usr/local/ucx --enable-mca-no-build=btl-uct && \
175+
make -j $(nproc) all && \
176+
make install && \
177+
ldconfig && \
178+
rm -rf /tmp/openmpi*
179+
180+
# Allow OpenSSH to talk to containers without asking for confirmation
181+
RUN mkdir -p /var/run/sshd && \
182+
cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \
183+
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \
184+
mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config
185+
186+
# Create a wrapper for OpenMPI to allow running as root by default
187+
RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real && \
188+
echo '#!/bin/bash' > /usr/local/bin/mpirun && \
189+
echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun && \
190+
chmod a+x /usr/local/bin/mpirun
191+
192+
# Configure OpenMPI to run good defaults:
193+
RUN echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf
194+
195+
# Install git-lfs
196+
WORKDIR /tmp
197+
RUN curl -sLO https://github.com/git-lfs/git-lfs/releases/download/v2.13.1/git-lfs-linux-amd64-v2.13.1.tar.gz && \
198+
tar -zxf git-lfs-linux-amd64-v2.13.1.tar.gz && \
199+
bash install.sh && \
200+
rm -rf /tmp/*
201+
202+
# Install VSCode
203+
RUN curl -fL https://github.com/cdr/code-server/releases/download/v3.8.0/code-server-3.8.0-linux-amd64.tar.gz \
204+
| tar -C /usr/local/lib -xz && \
205+
mv /usr/local/lib/code-server-3.8.0-linux-amd64 /usr/local/lib/code-server-3.8.0 && \
206+
ln -s /usr/local/lib/code-server-3.8.0/bin/code-server /usr/local/bin/code-server
207+
208+
RUN /opt/conda/bin/conda install \
209+
pytorch \
210+
torchvision \
211+
torchaudio \
212+
cudatoolkit=10.1 \
213+
-c pytorch \
214+
-c conda-forge
215+
RUN /opt/conda/bin/python3 -m pip install --no-cache-dir \
216+
Cython==0.29.22 \
217+
tornado==6.1 \
218+
pystan==3.0.1 \
219+
pycairo==1.20.0 \
220+
numpy==1.20.2 \
221+
tensorflow==2.3.2 \
222+
scipy==1.6.3 \
223+
scikit-learn==0.24.2 \
224+
jupyter==1.0.0 \
225+
typeguard==2.11.1 \
226+
python-language-server[all] \
227+
matplotlib==3.4.1
228+
229+
WORKDIR /tmp
230+
COPY ./requirements.txt /tmp
231+
RUN /opt/conda/bin/python3 -m pip install --no-cache-dir --ignore-installed -r requirements.txt && \
232+
rm -f /tmp/*.whl /tmp/requirements.txt
233+
234+
# Install Jupyterlab extensions
235+
RUN jupyter nbextensions_configurator enable && \
236+
jupyter contrib nbextension install && \
237+
jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
238+
jupyter serverextension enable --py jupyter_lsp && \
239+
jupyter nbextension enable execute_time/ExecuteTime && \
240+
jupyter nbextension enable toc2/main
241+
242+
# Copy Backend.Ai multi-node support
243+
COPY ./runner-scripts/bootstrap.sh /opt/container/
244+
COPY ./service-defs /etc/backend.ai/service-defs
245+
246+
# Install ipython kernelspec
247+
Run /opt/conda/bin/python3 -m ipykernel install --display-name "Conda python 3.8 on CUDA 10.1 & CentOS 8" && \
248+
cat /usr/local/share/jupyter/kernels/python3/kernel.json
249+
250+
# Backend.AI specifics
251+
LABEL ai.backend.kernelspec="1" \
252+
ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
253+
ai.backend.features="batch query uid-match user-input" \
254+
ai.backend.base-distro="ubuntu16.04" \
255+
ai.backend.resource.min.cpu="1" \
256+
ai.backend.resource.min.mem="1g" \
257+
ai.backend.resource.min.cuda.device=0 \
258+
ai.backend.resource.min.cuda.shares=0 \
259+
ai.backend.runtime-type="python" \
260+
ai.backend.runtime-path="/opt/conda/bin/python3" \
261+
ai.backend.service-ports="ipython:pty:3000,jupyter:http:8081,vscode:http:8180,tensorboard:http:6006"
262+
263+
WORKDIR /home/work
264+
# vim: ft=dockerfile

0 commit comments

Comments
 (0)