File size: 3,482 Bytes
b386992
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
98
99
# 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 base-image
ENV PIP_CONSTRAINT=""
ARG IMAGE_LABEL
LABEL "nemo.library"=${IMAGE_LABEL}

ENV TRANSFORMERS_OFFLINE=0
ENV HYDRA_FULL_ERROR=1
ENV PYTHONUNBUFFERED=1

# APT packages
RUN bash -ex <<"EOF"
apt-get update
apt-get install -y bc
apt-get clean
EOF

WORKDIR /opt/NeMo
ARG TRTLLM_REPO
ARG TRTLLM_TAG
RUN --mount=type=bind,source=docker/common/install_dep.sh,target=/opt/NeMo/install_dep.sh \
  --mount=type=bind,source=external/patches,target=/opt/NeMo/external/patches bash -ex <<"EOF"

  bash /opt/NeMo/install_dep.sh --library trt --mode install
EOF

FROM base-image AS trt-llm-wheel
WORKDIR /opt/NeMo
ARG TRTLLM_REPO
ARG TRTLLM_TAG
RUN --mount=type=bind,source=docker/common/install_dep.sh,target=/opt/NeMo/install_dep.sh \
  --mount=type=bind,source=external/patches,target=/opt/NeMo/external/patches bash -ex <<"EOF"

  bash /opt/NeMo/install_dep.sh --library trtllm --mode build
EOF

FROM base-image as te-wheel
WORKDIR /opt/NeMo
ARG TE_REPO
ARG TE_TAG
RUN --mount=type=bind,source=docker/common/install_dep.sh,target=/opt/NeMo/install_dep.sh \
  --mount=type=bind,source=external/patches,target=/opt/NeMo/external/patches bash -ex <<"EOF"

  bash /opt/NeMo/install_dep.sh --library te --mode build
  ls -al /opt/Megatron-LM || true
EOF

FROM base-image as mcore-wheel
WORKDIR /opt/NeMo
ARG MLM_REPO
ARG MLM_TAG
RUN --mount=type=bind,source=docker/common/install_dep.sh,target=/opt/NeMo/install_dep.sh bash -ex <<"EOF"

  bash /opt/NeMo/install_dep.sh --library mcore --mode build
  ls -al /opt/Megatron-LM || true
EOF

FROM base-image
WORKDIR /opt/NeMo
ENV INSTALL_DIR="/opt"
RUN \
  --mount=type=bind,from=trt-llm-wheel,source=/opt/wheels/trtllm,target=/opt/wheels/trtllm \
  --mount=type=bind,from=te-wheel,source=/opt/wheels/te,target=/opt/wheels/te \
  --mount=type=bind,from=mcore-wheel,source=/opt/wheels/mcore,target=/opt/wheels/mcore \
  --mount=type=bind,source=requirements,target=/opt/NeMo/requirements \
  --mount=type=bind,source=tools/ctc_segmentation/requirements.txt,target=/opt/NeMo/tools/ctc_segmentation/requirements.txt \
  --mount=type=bind,source=docker/common/install_dep.sh,target=/opt/NeMo/install_dep.sh \
  --mount=type=bind,source=setup.py,target=/opt/NeMo/setup.py \
  --mount=type=bind,source=external/patches,target=/opt/NeMo/external/patches \
  --mount=type=bind,source=README.md,target=/opt/NeMo/README.md \
  --mount=type=bind,source=nemo/package_info.py,target=/opt/NeMo/nemo/package_info.py \
  --mount=type=bind,source=nemo/__init__.py,target=/opt/NeMo/nemo/__init__.py bash -ex <<"EOF"

    bash /opt/NeMo/install_dep.sh --library all --mode install
    pip install --no-cache-dir ".[deploy,test]"

EOF

WORKDIR /workspace
ENV PYTHONPATH="${PYTHONPATH}:/workspace/Megatron-LM"
ENV NEMO_HOME="/home/TestData/nemo_home"