Dockerfile 8.05 KB
Newer Older
1
2
FROM nvidia/cuda:10.0-devel-ubuntu18.04

Jeff Rasley's avatar
Jeff Rasley committed
3
4
5
6
7
8
##############################################################################
# Temporary Installation Directory
##############################################################################
ENV STAGE_DIR=/tmp
RUN mkdir -p ${STAGE_DIR}

9
10
11
12
##############################################################################
# Installation/Basic Utilities
##############################################################################
RUN apt-get update && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
13
        apt-get install -y --no-install-recommends \
Jeff Rasley's avatar
Jeff Rasley committed
14
15
16
17
18
19
20
        software-properties-common build-essential autotools-dev \
        nfs-common pdsh \
        cmake g++ gcc \
        curl wget vim tmux emacs less unzip \
        htop iftop iotop ca-certificates openssh-client openssh-server \
        rsync iputils-ping net-tools sudo \
        llvm-9-dev
21
22
23
24
25

##############################################################################
# Installation Latest Git
##############################################################################
RUN add-apt-repository ppa:git-core/ppa -y && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
26
27
28
        apt-get update && \
        apt-get install -y git && \
        git --version
29

Jeff Rasley's avatar
Jeff Rasley committed
30
31
32
33
34
35
##############################################################################
# Client Liveness & Uncomment Port 22 for SSH Daemon
##############################################################################
# Keep SSH client alive from server side
RUN echo "ClientAliveInterval 30" >> /etc/ssh/sshd_config
RUN cp /etc/ssh/sshd_config ${STAGE_DIR}/sshd_config && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
36
        sed "0,/^#Port 22/s//Port 22/" ${STAGE_DIR}/sshd_config > /etc/ssh/sshd_config
Jeff Rasley's avatar
Jeff Rasley committed
37
38
39
40
41
42
43

##############################################################################
# Mellanox OFED
##############################################################################
ENV MLNX_OFED_VERSION=4.6-1.0.1.1
RUN apt-get install -y libnuma-dev
RUN cd ${STAGE_DIR} && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
44
45
46
47
48
        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 - && \
        cd MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64 && \
        ./mlnxofedinstall --user-space-only --without-fw-update --all -q && \
        cd ${STAGE_DIR} && \
        rm -rf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64*
Jeff Rasley's avatar
Jeff Rasley committed
49
50
51
52
53
54
55

##############################################################################
# nv_peer_mem
##############################################################################
ENV NV_PEER_MEM_VERSION=1.1
ENV NV_PEER_MEM_TAG=1.1-0
RUN mkdir -p ${STAGE_DIR} && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
56
57
58
59
60
61
62
63
64
65
        git clone https://github.com/Mellanox/nv_peer_memory.git --branch ${NV_PEER_MEM_TAG} ${STAGE_DIR}/nv_peer_memory && \
        cd ${STAGE_DIR}/nv_peer_memory && \
        ./build_module.sh && \
        cd ${STAGE_DIR} && \
        tar xzf ${STAGE_DIR}/nvidia-peer-memory_${NV_PEER_MEM_VERSION}.orig.tar.gz && \
        cd ${STAGE_DIR}/nvidia-peer-memory-${NV_PEER_MEM_VERSION} && \
        apt-get update && \
        apt-get install -y dkms && \
        dpkg-buildpackage -us -uc && \
        dpkg -i ${STAGE_DIR}/nvidia-peer-memory_${NV_PEER_MEM_TAG}_all.deb
Jeff Rasley's avatar
Jeff Rasley committed
66

Jeff Rasley's avatar
Jeff Rasley committed
67
68
69
70
71
72
##############################################################################
# OPENMPI
##############################################################################
ENV OPENMPI_BASEVERSION=4.0
ENV OPENMPI_VERSION=${OPENMPI_BASEVERSION}.1
RUN cd ${STAGE_DIR} && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
73
74
75
76
77
78
79
80
81
        wget -q -O - https://download.open-mpi.org/release/open-mpi/v${OPENMPI_BASEVERSION}/openmpi-${OPENMPI_VERSION}.tar.gz | tar xzf - && \
        cd openmpi-${OPENMPI_VERSION} && \
        ./configure --prefix=/usr/local/openmpi-${OPENMPI_VERSION} && \
        make -j"$(nproc)" install && \
        ln -s /usr/local/openmpi-${OPENMPI_VERSION} /usr/local/mpi && \
        # Sanity check:
        test -f /usr/local/mpi/bin/mpic++ && \
        cd ${STAGE_DIR} && \
        rm -r ${STAGE_DIR}/openmpi-${OPENMPI_VERSION}
Jeff Rasley's avatar
Jeff Rasley committed
82
ENV PATH=/usr/local/mpi/bin:${PATH} \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
83
        LD_LIBRARY_PATH=/usr/local/lib:/usr/local/mpi/lib:/usr/local/mpi/lib64:${LD_LIBRARY_PATH}
Jeff Rasley's avatar
Jeff Rasley committed
84
85
# Create a wrapper for OpenMPI to allow running as root by default
RUN mv /usr/local/mpi/bin/mpirun /usr/local/mpi/bin/mpirun.real && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
86
87
88
        echo '#!/bin/bash' > /usr/local/mpi/bin/mpirun && \
        echo 'mpirun.real --allow-run-as-root --prefix /usr/local/mpi "$@"' >> /usr/local/mpi/bin/mpirun && \
        chmod a+x /usr/local/mpi/bin/mpirun
Jeff Rasley's avatar
Jeff Rasley committed
89

90
91
92
93
94
95
##############################################################################
# Python
##############################################################################
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHON_VERSION=3
RUN apt-get install -y python3 python3-dev && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
96
97
        rm -f /usr/bin/python && \
        ln -s /usr/bin/python3 /usr/bin/python && \
aiss's avatar
aiss committed
98
        curl -O https://bootstrap.pypa.io/pip/3.6/get-pip.py && \
99
100
        python get-pip.py && \
        rm get-pip.py && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
101
102
103
        pip install --upgrade pip && \
        # Print python an pip version
        python -V && pip -V
Jeff Rasley's avatar
Jeff Rasley committed
104
RUN pip install pyyaml
Jeff Rasley's avatar
Jeff Rasley committed
105
RUN pip install ipython
106
107
108
109

##############################################################################
# TensorFlow
##############################################################################
110
ENV TENSORFLOW_VERSION=1.15.2
111
112
RUN pip install tensorflow-gpu==${TENSORFLOW_VERSION}

Jeff Rasley's avatar
Jeff Rasley committed
113
114
115
116
##############################################################################
# Some Packages
##############################################################################
RUN apt-get update && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
117
        apt-get install -y --no-install-recommends \
Jeff Rasley's avatar
Jeff Rasley committed
118
119
120
121
        libsndfile-dev \
        libcupti-dev \
        libjpeg-dev \
        libpng-dev \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
122
123
        screen \
        libaio-dev
Jeff Rasley's avatar
Jeff Rasley committed
124
RUN pip install psutil \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
        yappi \
        cffi \
        ipdb \
        pandas \
        matplotlib \
        py3nvml \
        pyarrow \
        graphviz \
        astor \
        boto3 \
        tqdm \
        sentencepiece \
        msgpack \
        requests \
        pandas \
        sphinx \
        sphinx_rtd_theme \
        scipy \
        numpy \
        sklearn \
        scikit-learn \
        nvidia-ml-py3 \
        mpi4py \
        cupy-cuda100
Jeff Rasley's avatar
Jeff Rasley committed
149
150
151
152
153
154

##############################################################################
## SSH daemon port inside container cannot conflict with host OS port
###############################################################################
ENV SSH_PORT=2222
RUN cat /etc/ssh/sshd_config > ${STAGE_DIR}/sshd_config && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
155
        sed "0,/^#Port 22/s//Port ${SSH_PORT}/" ${STAGE_DIR}/sshd_config > /etc/ssh/sshd_config
Jeff Rasley's avatar
Jeff Rasley committed
156

157
158
159
160
161
162
163
164
165
166
167
##############################################################################
# PyTorch
##############################################################################
ENV PYTORCH_VERSION=1.2.0
ENV TORCHVISION_VERSION=0.4.0
ENV TENSORBOARDX_VERSION=1.8
RUN pip install torch==${PYTORCH_VERSION}
RUN pip install torchvision==${TORCHVISION_VERSION}
RUN pip install tensorboardX==${TENSORBOARDX_VERSION}

##############################################################################
Jeff Rasley's avatar
Jeff Rasley committed
168
169
# PyYAML build issue
# https://stackoverflow.com/a/53926898
170
##############################################################################
Jeff Rasley's avatar
Jeff Rasley committed
171
RUN rm -rf /usr/lib/python3/dist-packages/yaml && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
172
        rm -rf /usr/lib/python3/dist-packages/PyYAML-*
173
174
175
176
177
178
179
180
181
182
183
184
185
186

##############################################################################
## Add deepspeed user
###############################################################################
# Add a deepspeed user with user id 8877
#RUN useradd --create-home --uid 8877 deepspeed
RUN useradd --create-home --uid 1000 --shell /bin/bash deepspeed
RUN usermod -aG sudo deepspeed
RUN echo "deepspeed ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# # Change to non-root privilege
USER deepspeed

##############################################################################
# DeepSpeed
Jeff Rasley's avatar
Jeff Rasley committed
187
188
189
##############################################################################
RUN git clone https://github.com/microsoft/DeepSpeed.git ${STAGE_DIR}/DeepSpeed
RUN cd ${STAGE_DIR}/DeepSpeed && \
Samyam Rajbhandari's avatar
Samyam Rajbhandari committed
190
191
192
        git checkout . && \
        git checkout master && \
        ./install.sh --pip_sudo
Jeff Rasley's avatar
Jeff Rasley committed
193
194
RUN rm -rf ${STAGE_DIR}/DeepSpeed
RUN python -c "import deepspeed; print(deepspeed.__version__)"