diff --git a/Dockerfile-CPU b/Dockerfile-CPU index 100faf326..05f22d298 100644 --- a/Dockerfile-CPU +++ b/Dockerfile-CPU @@ -1,27 +1,54 @@ FROM ubuntu:22.04 + LABEL github="https://github.com/mlcommons/GaNDLF" LABEL docs="https://mlcommons.github.io/GaNDLF/" LABEL version=1.0 -# ARG SETUPTOOLS_USE_DISTUTILS=local + ARG DEBIAN_FRONTEND=noninteractive +ARG BUILD_TYPE=cpu + +# Install jq early to parse JSON +RUN apt-get update && apt-get install -y jq + +# Copy and read versions file +COPY versions.json /tmp/versions.json + +# Display versions being used +RUN echo "=== Building ${BUILD_TYPE} version with the following versions ===" && \ + cat /tmp/versions.json && \ + echo "===========================================" # Install fresh Python and dependencies for build-from-source -RUN apt-get update && apt-get install -y software-properties-common -RUN apt-get install -y git -RUN add-apt-repository ppa:deadsnakes/ppa -RUN apt install -y python3.11 -RUN apt install -y libpython3.11-dev -RUN apt install -y libpython3.11 -# RUN apt install -y python-distutils-extra -RUN apt install -y python3.11-venv -# RUN apt install -y python-setuptools -RUN apt install -y python3-pip +RUN apt-get install -y software-properties-common git + +# Install Python using version from JSON +RUN PYTHON_VERSION=$(jq -r '.python' /tmp/versions.json) && \ + echo "Installing Python ${PYTHON_VERSION}" && \ + add-apt-repository ppa:deadsnakes/ppa && \ + apt install -y python${PYTHON_VERSION} \ + libpython${PYTHON_VERSION}-dev \ + libpython${PYTHON_VERSION} \ + python${PYTHON_VERSION}-venv \ + python3-pip + +# Install additional dependencies RUN apt-get install -y libjpeg8-dev zlib1g-dev libffi-dev libgl1 -# fix pip version because of weird PyYAML issue + +# Fix pip version because of weird PyYAML issue RUN python3.11 -m pip install --upgrade pip RUN python3.11 -m pip install uv -# EXPLICITLY install cpu versions of torch/torchvision (not all versions have +cpu modes on PyPI...) -RUN uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cpu --system + +# EXPLICITLY install cpu versions of torch/torchvision using versions from JSON +RUN PYTORCH_VERSION=$(jq -r '.pytorch.version' /tmp/versions.json) && \ + TORCHVISION_VERSION=$(jq -r '.pytorch.torchvision' /tmp/versions.json) && \ + TORCHAUDIO_VERSION=$(jq -r '.pytorch.torchaudio' /tmp/versions.json) && \ + PYTORCH_INDEX=$(jq -r '.pytorch.index.cpu' /tmp/versions.json) && \ + echo "Installing PyTorch ${PYTORCH_VERSION} (${PYTORCH_INDEX}), TorchVision ${TORCHVISION_VERSION}, TorchAudio ${TORCHAUDIO_VERSION}" && \ + uv pip install torch==${PYTORCH_VERSION} \ + torchvision==${TORCHVISION_VERSION} \ + torchaudio==${TORCHAUDIO_VERSION} \ + --index-url https://download.pytorch.org/whl/${PYTORCH_INDEX} --system + RUN uv pip install openvino-dev opencv-python-headless --system # Do some dependency installation separately here to make layer caching more efficient @@ -32,6 +59,7 @@ RUN python3.11 -c "from setup import requirements; file = open('requirements.txt COPY . /GaNDLF WORKDIR /GaNDLF RUN uv pip install -e . --system + # Entrypoint forces all commands given via "docker run" to go through python, CMD forces the default entrypoint script argument to be gandlf run # If a user calls "docker run gandlf:[tag] anonymize", it will resolve to running "gandlf anonymize" instead. # CMD is inherently overridden by args to "docker run", entrypoint is constant. @@ -48,4 +76,4 @@ CMD run #USER nonroot # Prepare the container for possible model embedding later. -RUN mkdir /embedded_model +RUN mkdir /embedded_model \ No newline at end of file diff --git a/Dockerfile-CUDA11.8 b/Dockerfile-CUDA11.8 index b9723e46f..cf05c1e3f 100644 --- a/Dockerfile-CUDA11.8 +++ b/Dockerfile-CUDA11.8 @@ -1,29 +1,56 @@ FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 + LABEL github="https://github.com/mlcommons/GaNDLF" LABEL docs="https://mlcommons.github.io/GaNDLF/" LABEL version=1.0 -# ARG SETUPTOOLS_USE_DISTUTILS=local # Install instructions for NVIDIA Container Toolkit allowing you to use the host's GPU: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html # Note that to do this on a Windows host you need experimental feature "CUDA on WSL" -- not yet stable. -ENV DEBIAN_FRONTEND=noninteractive - -# Explicitly install python3.11 (this uses 11.1 for now, as PyTorch LTS 1.8.2 is built against it) -RUN apt-get update && apt-get install -y software-properties-common -RUN apt-get install -y git -RUN add-apt-repository ppa:deadsnakes/ppa -RUN apt install -y python3.11 -RUN apt install -y libpython3.11-dev -RUN apt install -y libpython3.11 -# RUN apt install -y python-distutils-extra -RUN apt install -y python3.11-venv -# RUN apt install -y python-setuptools -RUN apt install -y python3-pip +ENV DEBIAN_FRONTEND=noninteractive +ARG BUILD_TYPE=cuda118 + +# Install jq early to parse JSON +RUN apt-get update && apt-get install -y jq + +# Copy and read versions file +COPY versions.json /tmp/versions.json + +# Display versions being used +RUN echo "=== Building ${BUILD_TYPE} version with the following versions ===" && \ + cat /tmp/versions.json && \ + echo "===========================================" + +# Explicitly install python3.11 +RUN apt-get install -y software-properties-common git + +# Install Python using version from JSON +RUN PYTHON_VERSION=$(jq -r '.python' /tmp/versions.json) && \ + echo "Installing Python ${PYTHON_VERSION}" && \ + add-apt-repository ppa:deadsnakes/ppa && \ + apt install -y python${PYTHON_VERSION} \ + libpython${PYTHON_VERSION}-dev \ + libpython${PYTHON_VERSION} \ + python${PYTHON_VERSION}-venv \ + python3-pip + +# Install additional dependencies RUN apt-get install -y libjpeg8-dev zlib1g-dev libffi-dev libgl1 -# fix pip version because of weird PyYAML issue + +# Fix pip version because of weird PyYAML issue RUN python3.11 -m pip install --upgrade pip RUN python3.11 -m pip install uv -RUN uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu118 --system + +# Install PyTorch packages with CUDA 11.8 support using versions from JSON +RUN PYTORCH_VERSION=$(jq -r '.pytorch.version' /tmp/versions.json) && \ + TORCHVISION_VERSION=$(jq -r '.pytorch.torchvision' /tmp/versions.json) && \ + TORCHAUDIO_VERSION=$(jq -r '.pytorch.torchaudio' /tmp/versions.json) && \ + PYTORCH_INDEX=$(jq -r '.pytorch.index.cuda118' /tmp/versions.json) && \ + echo "Installing PyTorch ${PYTORCH_VERSION} (${PYTORCH_INDEX}), TorchVision ${TORCHVISION_VERSION}, TorchAudio ${TORCHAUDIO_VERSION}" && \ + uv pip install torch==${PYTORCH_VERSION} \ + torchvision==${TORCHVISION_VERSION} \ + torchaudio==${TORCHAUDIO_VERSION} \ + --index-url https://download.pytorch.org/whl/${PYTORCH_INDEX} --system + RUN uv pip install openvino-dev opencv-python-headless --system # Do some dependency installation separately here to make layer caching more efficient @@ -51,4 +78,4 @@ CMD run #USER nonroot # Prepare the container for possible model embedding later. -RUN mkdir /embedded_model +RUN mkdir /embedded_model \ No newline at end of file diff --git a/Dockerfile-CUDA12.6 b/Dockerfile-CUDA12.6 index 6ce933b82..514935e34 100644 --- a/Dockerfile-CUDA12.6 +++ b/Dockerfile-CUDA12.6 @@ -1,29 +1,56 @@ FROM nvidia/cuda:12.6.3-cudnn-devel-ubuntu22.04 + LABEL github="https://github.com/mlcommons/GaNDLF" LABEL docs="https://mlcommons.github.io/GaNDLF/" LABEL version=1.0 -# ARG SETUPTOOLS_USE_DISTUTILS=local # Install instructions for NVIDIA Container Toolkit allowing you to use the host's GPU: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html # Note that to do this on a Windows host you need experimental feature "CUDA on WSL" -- not yet stable. -ENV DEBIAN_FRONTEND=noninteractive - -# Explicitly install python3.11 (this uses 11.1 for now, as PyTorch LTS 1.8.2 is built against it) -RUN apt-get update && apt-get install -y software-properties-common -RUN apt-get install -y git -RUN add-apt-repository ppa:deadsnakes/ppa -RUN apt install -y python3.11 -RUN apt install -y libpython3.11-dev -RUN apt install -y libpython3.11 -# RUN apt install -y python-distutils-extra -RUN apt install -y python3.11-venv -# RUN apt install -y python-setuptools -RUN apt install -y python3-pip +ENV DEBIAN_FRONTEND=noninteractive +ARG BUILD_TYPE=cuda126 + +# Install jq early to parse JSON +RUN apt-get update && apt-get install -y jq + +# Copy and read versions file +COPY versions.json /tmp/versions.json + +# Display versions being used +RUN echo "=== Building ${BUILD_TYPE} version with the following versions ===" && \ + cat /tmp/versions.json && \ + echo "===========================================" + +# Explicitly install python3.11 +RUN apt-get install -y software-properties-common git + +# Install Python using version from JSON +RUN PYTHON_VERSION=$(jq -r '.python' /tmp/versions.json) && \ + echo "Installing Python ${PYTHON_VERSION}" && \ + add-apt-repository ppa:deadsnakes/ppa && \ + apt install -y python${PYTHON_VERSION} \ + libpython${PYTHON_VERSION}-dev \ + libpython${PYTHON_VERSION} \ + python${PYTHON_VERSION}-venv \ + python3-pip + +# Install additional dependencies RUN apt-get install -y libjpeg8-dev zlib1g-dev libffi-dev libgl1 -# fix pip version because of weird PyYAML issue + +# Fix pip version because of weird PyYAML issue RUN python3.11 -m pip install --upgrade pip RUN python3.11 -m pip install uv -RUN uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu126 --system + +# Install PyTorch packages with CUDA 12.6 support using versions from JSON +RUN PYTORCH_VERSION=$(jq -r '.pytorch.version' /tmp/versions.json) && \ + TORCHVISION_VERSION=$(jq -r '.pytorch.torchvision' /tmp/versions.json) && \ + TORCHAUDIO_VERSION=$(jq -r '.pytorch.torchaudio' /tmp/versions.json) && \ + PYTORCH_INDEX=$(jq -r '.pytorch.index.cuda126' /tmp/versions.json) && \ + echo "Installing PyTorch ${PYTORCH_VERSION} (${PYTORCH_INDEX}), TorchVision ${TORCHVISION_VERSION}, TorchAudio ${TORCHAUDIO_VERSION}" && \ + uv pip install torch==${PYTORCH_VERSION} \ + torchvision==${TORCHVISION_VERSION} \ + torchaudio==${TORCHAUDIO_VERSION} \ + --index-url https://download.pytorch.org/whl/${PYTORCH_INDEX} --system + RUN uv pip install openvino-dev opencv-python-headless --system # Do some dependency installation separately here to make layer caching more efficient @@ -51,4 +78,4 @@ CMD run #USER nonroot # Prepare the container for possible model embedding later. -RUN mkdir /embedded_model +RUN mkdir /embedded_model \ No newline at end of file diff --git a/Dockerfile-ROCm b/Dockerfile-ROCm index fe2622e37..fcf075351 100644 --- a/Dockerfile-ROCm +++ b/Dockerfile-ROCm @@ -1,27 +1,55 @@ FROM rocm/pytorch:rocm6.3.4_ubuntu22.04_py3.10_pytorch_release_2.4.0 + LABEL github="https://github.com/mlcommons/GaNDLF" LABEL docs="https://mlcommons.github.io/GaNDLF/" LABEL version=1.0 -# ARG SETUPTOOLS_USE_DISTUTILS=local # Quick start instructions on using Docker with ROCm: https://github.com/RadeonOpenCompute/ROCm-docker/blob/master/quick-start.md +ARG BUILD_TYPE=rocm + +# Install jq early to parse JSON +RUN apt-get update && apt-get install -y jq + +# Copy and read versions file +COPY versions.json /tmp/versions.json + +# Display versions being used +RUN echo "=== Building ${BUILD_TYPE} version with the following versions ===" && \ + cat /tmp/versions.json && \ + echo "===========================================" + # The base image contains ROCm, python 3.9 and pytorch already, no need to install those -RUN apt-get update && apt-get install -y software-properties-common -RUN apt-get install -y git -RUN add-apt-repository ppa:deadsnakes/ppa -RUN apt install -y python3.11 -RUN apt install -y libpython3.11-dev -RUN apt install -y libpython3.11 -# RUN apt install -y python-distutils-extra -RUN apt install -y python3.11-venv -# RUN apt install -y python-setuptools -RUN apt install -y python3-pip -RUN apt-get install -y python3.11 python3-pip libjpeg8-dev zlib1g-dev python3-dev libpython3.11-dev libffi-dev libgl1 -# fix pip version because of weird PyYAML issue +RUN apt-get install -y software-properties-common git + +# Install Python using version from JSON +RUN PYTHON_VERSION=$(jq -r '.python' /tmp/versions.json) && \ + echo "Installing Python ${PYTHON_VERSION}" && \ + add-apt-repository ppa:deadsnakes/ppa && \ + apt install -y python${PYTHON_VERSION} \ + libpython${PYTHON_VERSION}-dev \ + libpython${PYTHON_VERSION} \ + python${PYTHON_VERSION}-venv \ + python3-pip + +# Install additional dependencies +RUN apt-get install -y libjpeg8-dev zlib1g-dev python3-dev libffi-dev libgl1 + +# Fix pip version because of weird PyYAML issue RUN python3.11 -m pip install --upgrade pip RUN python3.11 -m pip install uv -RUN uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/rocm6.3 --system + +# Install PyTorch packages with ROCm support using versions from JSON +RUN PYTORCH_VERSION=$(jq -r '.pytorch.version' /tmp/versions.json) && \ + TORCHVISION_VERSION=$(jq -r '.pytorch.torchvision' /tmp/versions.json) && \ + TORCHAUDIO_VERSION=$(jq -r '.pytorch.torchaudio' /tmp/versions.json) && \ + PYTORCH_INDEX=$(jq -r '.pytorch.index.rocm' /tmp/versions.json) && \ + echo "Installing PyTorch ${PYTORCH_VERSION} (${PYTORCH_INDEX}), TorchVision ${TORCHVISION_VERSION}, TorchAudio ${TORCHAUDIO_VERSION}" && \ + uv pip install torch==${PYTORCH_VERSION} \ + torchvision==${TORCHVISION_VERSION} \ + torchaudio==${TORCHAUDIO_VERSION} \ + --index-url https://download.pytorch.org/whl/${PYTORCH_INDEX} --system + RUN uv pip install openvino-dev opencv-python-headless --system # Do some dependency installation separately here to make layer caching more efficient @@ -39,7 +67,6 @@ RUN uv pip install -e . --system ENTRYPOINT gandlf CMD run - # The below force the container commands to run as a nonroot user with UID > 10000. # This greatly reduces UID collision probability between container and host, helping prevent privilege escalation attacks. # As a side benefit this also decreases the likelihood that users on a cluster won't be able to access their files. @@ -50,4 +77,4 @@ CMD run #USER nonroot # Prepare the container for possible model embedding later. -RUN mkdir /embedded_model +RUN mkdir /embedded_model \ No newline at end of file diff --git a/versions.json b/versions.json new file mode 100644 index 000000000..2d21e011d --- /dev/null +++ b/versions.json @@ -0,0 +1,18 @@ +{ + "python": "3.11", + "pytorch": { + "version": "2.7.1", + "torchvision": "0.22.1", + "torchaudio": "2.7.1", + "index": { + "cpu": "cpu", + "cuda118": "cu118", + "cuda126": "cu126", + "rocm": "rocm6.3" + } + }, + "dependencies": { + "pip": "latest", + "uv": "latest" + } +} \ No newline at end of file