-
-
Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathDockerfile
More file actions
81 lines (64 loc) · 2.21 KB
/
Dockerfile
File metadata and controls
81 lines (64 loc) · 2.21 KB
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
# syntax = edrevo/dockerfile-plus
ARG UBUNTU_VERSION
# Build stage
FROM nvidia/cuda:12.8.1-base-ubuntu${UBUNTU_VERSION}.04 AS builder
ENV NCCL_HOME=/opt/nccl
ENV CUDA_HOME=/usr/local/cuda
ENV OPEN_MPI_PATH=/usr/lib/x86_64-linux-gnu/openmpi
# Prerequisites
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}04/x86_64/3bf863cc.pub \
&& apt-get update --fix-missing \
&& apt-get upgrade -y \
&& ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime \
&& apt-get install -y tzdata \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& cuda_version=$(echo ${CUDA_VERSION} | awk -F . '{ print $1"-"$2 }') \
&& apt-get install -y --no-install-recommends \
cuda-libraries-dev-${cuda_version} \
cuda-nvcc-${cuda_version} \
libhwloc-dev \
autoconf \
automake \
libtool \
libopenmpi-dev \
git \
curl \
python3 \
build-essential
# NCCL
ARG NCCL_VERSION=2.26.2-1
RUN cd /tmp \
&& git clone https://github.com/NVIDIA/nccl.git -b v${NCCL_VERSION} \
&& cd nccl \
&& make -j$(nproc) src.build BUILDDIR=${NCCL_HOME}
# NCCL tests
RUN cd /opt \
&& git clone https://github.com/NVIDIA/nccl-tests \
&& cd nccl-tests \
&& make -j$(nproc) \
MPI=1 \
MPI_HOME=${OPEN_MPI_PATH} \
CUDA_HOME=${CUDA_HOME} \
NCCL_HOME=${NCCL_HOME}
# Final stage
INCLUDE+ base/Dockerfile.common
ENV NCCL_HOME=/opt/nccl
COPY --from=builder ${NCCL_HOME} ${NCCL_HOME}
COPY --from=builder /opt/nccl-tests/build /opt/nccl-tests/build
ARG FLAVOR
# MPI, NVCC, and /etc/ld.so.conf.d
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openmpi-bin \
&& if [ "$FLAVOR" = "devel" ]; then \
cuda_version=$(echo ${CUDA_VERSION} | awk -F . '{ print $1"-"$2 }') \
&& apt-get install -y --no-install-recommends \
cuda-libraries-dev-${cuda_version} \
cuda-nvcc-${cuda_version} \
libhwloc-dev; \
fi \
&& rm -rf /var/lib/apt/lists/* \
&& echo "${NCCL_HOME}/lib" >> /etc/ld.so.conf.d/nccl.conf \
&& ldconfig
WORKDIR /dstack/run