# 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"