Round3Fight / docker-examples /Dockerfile.custompytorch
Tyl3rDrden's picture
Upload folder using huggingface_hub
578b6a8 verified
#
# This example Dockerfile illustrates a method to apply
# patches to the source code in NVIDIA's PyTorch
# container image and to rebuild PyTorch. The RUN command
# included below will rebuild PyTorch in the same way as
# it was built in the original image.
#
# By applying customizations through a Dockerfile and
# `docker build` in this manner rather than modifying the
# container interactively, it will be straightforward to
# apply the same changes to later versions of the PyTorch
# container image.
#
# https://docs.docker.com/engine/reference/builder/
#
FROM nvcr.io/nvidia/pytorch:25.11-py3
# Bring in changes from outside container to /tmp
# (assumes my-pytorch-modifications.patch is in same directory as Dockerfile)
COPY my-pytorch-modifications.patch /tmp
# Change working directory to PyTorch source path
WORKDIR /opt/pytorch
# Apply modifications
RUN patch -p1 < /tmp/my-pytorch-modifications.patch
# Rebuild PyTorch
RUN cd pytorch && \
USE_CUPTI_SO=1 \
USE_KINETO=1 \
CMAKE_PREFIX_PATH="/usr/local" \
NCCL_ROOT="/usr" \
USE_SYSTEM_NCCL=1 \
USE_UCC=1 \
USE_SYSTEM_UCC=1 \
UCC_HOME="/opt/hpcx/ucc" \
# UCC_DIR is for PyTorch to find ucc-config.cmake
UCC_DIR="/opt/hpcx/ucc/lib/cmake/ucc" \
UCX_HOME="/opt/hpcx/ucx" \
UCX_DIR="/opt/hpcx/ucx/lib/cmake/ucx" \
CFLAGS='-fno-gnu-unique' \
DEFAULT_INTEL_MKL_DIR="/usr/local" \
INTEL_MKL_DIR="/usr/local" \
python setup.py install \
&& python setup.py clean
# Reset default working directory
WORKDIR /workspace