|
| 1 | +# syntax=docker/dockerfile:experimental |
| 2 | + |
| 3 | +# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# base image: official PyTorch image |
| 18 | +ARG BASE_IMAGE=pytorch/pytorch:2.11.0-cuda13.0-cudnn9-devel |
| 19 | + |
| 20 | +# check imports: if flag is false, ignore result |
| 21 | +ARG REQUIRE_CHECK_IMPORTS=true |
| 22 | + |
| 23 | +# build an image that includes only the nemo dependencies, ensures that dependencies |
| 24 | +# are included first for optimal caching, and useful for building a development |
| 25 | +# image (by specifying build target as `nemo-deps`) |
| 26 | +FROM ${BASE_IMAGE} as nemo-deps |
| 27 | + |
| 28 | +# necessary to install packages system-wide |
| 29 | +ENV UV_BREAK_SYSTEM_PACKAGES=true |
| 30 | + |
| 31 | +# Ensure apt-get won't prompt for selecting options |
| 32 | +ENV DEBIAN_FRONTEND=noninteractive |
| 33 | +RUN apt-get update && \ |
| 34 | + apt-get install -y \ |
| 35 | + git \ |
| 36 | + libsndfile1 sox \ |
| 37 | + libfreetype6 \ |
| 38 | + libsox-fmt-all \ |
| 39 | + swig \ |
| 40 | + ffmpeg && \ |
| 41 | + rm -rf /var/lib/apt/lists/* |
| 42 | + |
| 43 | +# copy nemo source into a scratch image |
| 44 | +FROM scratch as nemo-src |
| 45 | +COPY . . |
| 46 | + |
| 47 | +# start building the final container |
| 48 | +FROM nemo-deps as nemo |
| 49 | + |
| 50 | +RUN uv pip install cmake aistore --system |
| 51 | +# Install NeMo |
| 52 | +# NB: using constraints.txt is crucial to avoid breaking reinstallation of preinstalled torch ecosystem packages |
| 53 | +RUN --mount=from=nemo-src,target=/tmp/nemo,rw cd /tmp/nemo && uv pip freeze | grep torch > constraints.txt && \ |
| 54 | + uv pip install ".[all,cu13]" -c constraints.txt --system |
| 55 | + |
| 56 | +# Check install |
| 57 | +RUN CHECK_MSG=$(python -c "import nemo.collections.asr as nemo_asr" && \ |
| 58 | + python -c "import nemo.collections.audio as nemo_audio" && \ |
| 59 | + python -c "import nemo.collections.speechlm2 as nemo_speechlm2" && \ |
| 60 | + python -c "import nemo.collections.tts as nemo_tts" && \ |
| 61 | + python -c "import nemo_text_processing.text_normalization as text_normalization"); CHECK_CODE=$?; \ |
| 62 | + echo ${CHECK_MSG}; \ |
| 63 | + if [ ${CHECK_CODE} -ne 0 ]; then \ |
| 64 | + echo "Import check failed"; \ |
| 65 | + if [ "${REQUIRE_CHECK_IMPORTS}" = true ]; then \ |
| 66 | + exit ${CHECK_CODE}; \ |
| 67 | + else echo "Skipping unsuccessful import check"; fi \ |
| 68 | + else echo "Import check success"; fi |
| 69 | + |
| 70 | + |
| 71 | +# copy scripts/examples/tests into container for end user |
| 72 | +WORKDIR /workspace/nemo |
| 73 | +COPY scripts /workspace/nemo/scripts |
| 74 | +COPY examples /workspace/nemo/examples |
| 75 | +COPY tests /workspace/nemo/tests |
| 76 | +COPY tutorials /workspace/nemo/tutorials |
0 commit comments