Skip to content

Commit 2223816

Browse files
authored
Dockerfile: build from the official PyTorch image (#15638)
* Add Dockerfile from official PyTorch container --------- Signed-off-by: Vladimir Bataev <vbataev@nvidia.com>
1 parent 469a50a commit 2223816

2 files changed

Lines changed: 77 additions & 1 deletion

File tree

docker/Dockerfile.stable

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
nemo_automodel @ git+https://github.com/NVIDIA-NeMo/Automodel.git@cadbba77a6466f1acdabd7382fd90e0c3f821c19
1+
nemo_automodel @ git+https://github.com/NVIDIA-NeMo/Automodel.git@9eccbb6102a260efd7cbdffa890fc57b94f94528 # version with relaxed pytorch constraints
22
flashoptim

0 commit comments

Comments
 (0)