2020-10-02 09:26:21 +00:00
|
|
|
# Copyright The Lightning AI team.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2024-01-26 15:42:09 +00:00
|
|
|
ARG UBUNTU_VERSION=22.04
|
2023-01-04 22:44:23 +00:00
|
|
|
ARG CUDA_VERSION=11.7.1
|
2022-11-12 14:58:37 +00:00
|
|
|
|
2020-07-31 12:23:13 +00:00
|
|
|
|
2023-07-03 15:39:09 +00:00
|
|
|
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
|
2020-09-17 18:30:39 +00:00
|
|
|
|
2023-03-21 12:31:05 +00:00
|
|
|
ARG PYTHON_VERSION=3.10
|
2023-10-06 12:12:37 +00:00
|
|
|
ARG PYTORCH_VERSION=2.1
|
|
|
|
ARG MAX_ALLOWED_NCCL=2.17.1
|
2020-07-31 12:23:13 +00:00
|
|
|
|
2020-08-02 12:14:53 +00:00
|
|
|
SHELL ["/bin/bash", "-c"]
|
2020-10-26 10:47:09 +00:00
|
|
|
# https://techoverflow.net/2019/05/18/how-to-fix-configuring-tzdata-interactive-input-when-building-docker-images/
|
2021-01-29 12:27:18 +00:00
|
|
|
ENV \
|
2023-03-02 19:15:27 +00:00
|
|
|
DEBIAN_FRONTEND="noninteractive" \
|
|
|
|
TZ="Etc/UTC" \
|
2021-01-29 12:27:18 +00:00
|
|
|
PATH="$PATH:/root/.local/bin" \
|
2021-02-10 09:43:26 +00:00
|
|
|
CUDA_TOOLKIT_ROOT_DIR="/usr/local/cuda" \
|
2023-03-02 19:15:27 +00:00
|
|
|
MKL_THREADING_LAYER="GNU" \
|
2022-03-12 09:00:20 +00:00
|
|
|
# MAKEFLAGS="-j$(nproc)"
|
|
|
|
MAKEFLAGS="-j2"
|
2020-07-31 12:23:13 +00:00
|
|
|
|
2022-05-02 07:00:44 +00:00
|
|
|
RUN \
|
|
|
|
# TODO: Remove the manual key installation once the base image is updated.
|
|
|
|
# https://github.com/NVIDIA/nvidia-docker/issues/1631
|
2022-11-12 14:58:37 +00:00
|
|
|
# https://github.com/NVIDIA/nvidia-docker/issues/1631#issuecomment-1264715214
|
|
|
|
apt-get update && apt-get install -y wget && \
|
2024-01-26 15:42:09 +00:00
|
|
|
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub && \
|
2022-11-12 14:58:37 +00:00
|
|
|
mkdir -p /etc/apt/keyrings/ && mv 3bf863cc.pub /etc/apt/keyrings/ && \
|
|
|
|
echo "deb [signed-by=/etc/apt/keyrings/3bf863cc.pub] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /" /etc/apt/sources.list.d/cuda.list && \
|
2022-05-02 07:00:44 +00:00
|
|
|
apt-get update -qq --fix-missing && \
|
2022-08-25 17:30:06 +00:00
|
|
|
NCCL_VER=$(dpkg -s libnccl2 | grep '^Version:' | awk -F ' ' '{print $2}' | awk -F '-' '{print $1}' | grep -ve '^\s*$') && \
|
2023-03-02 19:15:27 +00:00
|
|
|
CUDA_VERSION_MM=${CUDA_VERSION%.*} && \
|
2022-08-25 17:30:06 +00:00
|
|
|
TO_INSTALL_NCCL=$(echo -e "$MAX_ALLOWED_NCCL\n$NCCL_VER" | sort -V | head -n1)-1+cuda${CUDA_VERSION_MM} && \
|
|
|
|
apt-get install -y --no-install-recommends --allow-downgrades --allow-change-held-packages \
|
2020-09-22 23:41:35 +00:00
|
|
|
build-essential \
|
2020-10-26 10:47:09 +00:00
|
|
|
pkg-config \
|
2020-09-22 23:41:35 +00:00
|
|
|
cmake \
|
|
|
|
git \
|
2020-10-26 10:47:09 +00:00
|
|
|
wget \
|
2021-01-08 15:36:49 +00:00
|
|
|
curl \
|
|
|
|
unzip \
|
2020-09-22 23:41:35 +00:00
|
|
|
ca-certificates \
|
2020-10-26 10:47:09 +00:00
|
|
|
software-properties-common \
|
2021-02-17 12:15:49 +00:00
|
|
|
libopenmpi-dev \
|
2022-05-06 02:56:57 +00:00
|
|
|
openmpi-bin \
|
|
|
|
ssh \
|
2022-10-11 11:59:09 +00:00
|
|
|
ninja-build \
|
2022-08-25 17:30:06 +00:00
|
|
|
libnccl2=$TO_INSTALL_NCCL \
|
|
|
|
libnccl-dev=$TO_INSTALL_NCCL && \
|
2022-10-11 11:59:09 +00:00
|
|
|
# Install python
|
2020-10-26 10:47:09 +00:00
|
|
|
add-apt-repository ppa:deadsnakes/ppa && \
|
|
|
|
apt-get install -y \
|
|
|
|
python${PYTHON_VERSION} \
|
|
|
|
python${PYTHON_VERSION}-distutils \
|
|
|
|
python${PYTHON_VERSION}-dev \
|
2020-08-02 12:14:53 +00:00
|
|
|
&& \
|
2020-10-26 10:47:09 +00:00
|
|
|
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
|
|
|
|
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \
|
2022-10-11 11:59:09 +00:00
|
|
|
# Cleaning
|
2020-08-02 12:14:53 +00:00
|
|
|
apt-get autoremove -y && \
|
|
|
|
apt-get clean && \
|
|
|
|
rm -rf /root/.cache && \
|
2020-09-17 18:30:39 +00:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2023-04-25 01:09:57 +00:00
|
|
|
COPY requirements/pytorch/ requirements/pytorch/
|
|
|
|
COPY requirements/_integrations/ requirements/_integrations/
|
2020-09-22 23:41:35 +00:00
|
|
|
|
2023-03-02 19:15:27 +00:00
|
|
|
ENV PYTHONPATH="/usr/lib/python${PYTHON_VERSION}/site-packages"
|
2022-02-16 20:15:44 +00:00
|
|
|
|
2020-09-17 18:30:39 +00:00
|
|
|
RUN \
|
2024-01-26 15:42:09 +00:00
|
|
|
curl https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} && \
|
2022-03-11 09:20:47 +00:00
|
|
|
# Disable cache \
|
2020-09-30 12:33:22 +00:00
|
|
|
pip config set global.cache-dir false && \
|
2022-12-22 06:21:52 +00:00
|
|
|
# set particular PyTorch version \
|
2023-05-29 19:34:04 +00:00
|
|
|
pip install -q wget packaging && \
|
|
|
|
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py && \
|
2022-12-22 06:21:52 +00:00
|
|
|
for fpath in `ls requirements/**/*.txt`; do \
|
2023-05-29 19:34:04 +00:00
|
|
|
python ./adjust-torch-versions.py $fpath ${PYTORCH_VERSION}; \
|
2022-12-22 06:21:52 +00:00
|
|
|
done && \
|
2023-03-02 19:15:27 +00:00
|
|
|
CUDA_VERSION_MM=${CUDA_VERSION%.*} && \
|
2023-06-26 17:12:53 +00:00
|
|
|
pip install --no-cache-dir \
|
2023-04-25 07:21:21 +00:00
|
|
|
-r requirements/pytorch/base.txt \
|
|
|
|
-r requirements/pytorch/extra.txt \
|
|
|
|
-r requirements/pytorch/test.txt \
|
2023-04-25 01:09:57 +00:00
|
|
|
-r requirements/pytorch/strategies.txt \
|
2024-01-26 15:42:09 +00:00
|
|
|
--find-links="https://download.pytorch.org/whl/cu${CUDA_VERSION_MM//'.'/''}/torch_stable.html" \
|
|
|
|
--find-links="https://download.pytorch.org/whl/test/cu${CUDA_VERSION_MM//'.'/''}/torch_test.html"
|
2022-04-11 15:29:54 +00:00
|
|
|
|
2020-09-30 12:33:22 +00:00
|
|
|
RUN \
|
2020-09-17 18:30:39 +00:00
|
|
|
# Show what we have
|
2020-08-15 19:39:44 +00:00
|
|
|
pip --version && \
|
2020-09-30 12:33:22 +00:00
|
|
|
pip list && \
|
2021-07-14 15:04:33 +00:00
|
|
|
python -c "import sys; ver = sys.version_info ; assert f'{ver.major}.{ver.minor}' == '$PYTHON_VERSION', ver" && \
|
2022-02-10 07:48:33 +00:00
|
|
|
python -c "import torch; assert torch.__version__.startswith('$PYTORCH_VERSION'), torch.__version__" && \
|
2022-06-21 15:11:33 +00:00
|
|
|
python requirements/pytorch/check-avail-extras.py && \
|
2022-05-12 13:14:18 +00:00
|
|
|
rm -rf requirements/
|