-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathDockerfile.ci
97 lines (83 loc) · 3.22 KB
/
Dockerfile.ci
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
# syntax=docker/dockerfile:1-labs
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG BASE_IMAGE=nvcr.io/nvidia/pytorch:24.07-py3
FROM ${BASE_IMAGE} as nemo-bump
ARG NEMO_TAG
WORKDIR /opt
# NeMo
RUN <<"EOF" bash -exu
if [[ ! -d NeMo ]]; then
git clone https://github.com/NVIDIA/NeMo.git
fi
cd NeMo/
git fetch origin '+refs/pull/*/merge:refs/remotes/pull/*/merge'
git fetch origin $NEMO_TAG
git checkout -f $NEMO_TAG
EOF
FROM ${BASE_IMAGE}
ARG IMAGE_LABEL
LABEL "nemo.library"=${IMAGE_LABEL}
ENV TRANSFORMERS_OFFLINE=0
ENV HYDRA_FULL_ERROR=1
ENV PYTHONUNBUFFERED=1
# APT packages
RUN <<"EOF" bash -ex
apt-get update
apt-get install -y bc libsox-fmt-all -y
apt-get clean
EOF
ARG MAX_JOBS
ARG TE_TAG
ARG TE_REPO
RUN --mount=type=bind,from=nemo-bump,source=/opt/NeMo/reinstall.sh,target=/opt/NeMo/reinstall.sh \
bash /opt/NeMo/reinstall.sh --library te --mode build && \
ls -al /opt/TransformerEngine || true
ARG APEX_REPO
ARG APEX_TAG
RUN --mount=type=bind,from=nemo-bump,source=/opt/NeMo/reinstall.sh,target=/opt/NeMo/reinstall.sh \
bash /opt/NeMo/reinstall.sh --library apex --mode build && \
ls -al /opt/Apex || true
ARG MLM_REPO
ARG MLM_TAG
RUN --mount=type=bind,from=nemo-bump,source=/opt/NeMo/reinstall.sh,target=/opt/NeMo/reinstall.sh \
bash /opt/NeMo/reinstall.sh --library mcore --mode build && \
ls -al /opt/Megatron-LM || true
WORKDIR /workspace
RUN \
--mount=type=bind,from=nemo-bump,source=/opt/NeMo/requirements,target=/tmp/NeMo/requirements \
--mount=type=bind,from=nemo-bump,source=/opt/NeMo/tools/ctc_segmentation/requirements.txt,target=/tmp/NeMo/tools/ctc_segmentation/requirements.txt \
--mount=type=bind,from=nemo-bump,source=/opt/NeMo/reinstall.sh,target=/tmp/NeMo/reinstall.sh \
--mount=type=bind,from=nemo-bump,source=/opt/NeMo/setup.py,target=/tmp/NeMo/setup.py \
--mount=type=bind,from=nemo-bump,source=/opt/NeMo/README.md,target=/tmp/NeMo/README.md \
--mount=type=bind,from=nemo-bump,source=/opt/NeMo/nemo/package_info.py,target=/tmp/NeMo/nemo/package_info.py \
--mount=type=bind,from=nemo-bump,source=/opt/NeMo/nemo/__init__.py,target=/tmp/NeMo/nemo/__init__.py <<"EOF" bash -ex
export NEMO_DIR=/tmp/NeMo
bash /tmp/NeMo/reinstall.sh --library all --mode install
rm -rf $NEMO_DIR || true
EOF
# Copy over NeMo code
ARG NEMO_REPO
ARG NEMO_TAG
RUN \
--mount=type=bind,from=nemo-bump,source=/opt/NeMo/reinstall.sh,target=/tmp/reinstall.sh <<"EOF" bash -ex
bash /tmp/reinstall.sh --library all --mode install
# Copy into workspace
cp -a /opt/NeMo/. /workspace/
cp -r /opt/Megatron-LM/ /workspace/
# set permission
chmod 777 -R /workspace
EOF
ENV PYTHONPATH="${PYTHONPATH}:/workspace/Megatron-LM"
ENV NEMO_HOME="/home/TestData/nemo_home"