|
| 1 | +# Copyright The Lightning AI team. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +ARG UBUNTU_VERSION=22.04 |
| 16 | +ARG CUDA_VERSION=11.8.0 |
| 17 | + |
| 18 | + |
| 19 | +FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION} |
| 20 | + |
| 21 | +ARG PYTHON_VERSION=3.10 |
| 22 | +ARG PYTORCH_VERSION=2.0 |
| 23 | + |
| 24 | +SHELL ["/bin/bash", "-c"] |
| 25 | +# https://techoverflow.net/2019/05/18/how-to-fix-configuring-tzdata-interactive-input-when-building-docker-images/ |
| 26 | +ENV \ |
| 27 | + DEBIAN_FRONTEND="noninteractive" \ |
| 28 | + TZ="Etc/UTC" \ |
| 29 | + PATH="$PATH:/root/.local/bin" \ |
| 30 | + CUDA_TOOLKIT_ROOT_DIR="/usr/local/cuda" \ |
| 31 | + MKL_THREADING_LAYER="GNU" \ |
| 32 | + # MAKEFLAGS="-j$(nproc)" |
| 33 | + MAKEFLAGS="-j2" |
| 34 | + |
| 35 | +RUN \ |
| 36 | + apt-get -y update --fix-missing && \ |
| 37 | + apt-get install -y --no-install-recommends --allow-downgrades --allow-change-held-packages \ |
| 38 | + build-essential \ |
| 39 | + ca-certificates \ |
| 40 | + software-properties-common \ |
| 41 | + pkg-config \ |
| 42 | + libopenmpi-dev \ |
| 43 | + openmpi-bin \ |
| 44 | + cmake \ |
| 45 | + git \ |
| 46 | + wget \ |
| 47 | + curl \ |
| 48 | + unzip \ |
| 49 | + g++ \ |
| 50 | + cmake \ |
| 51 | + ffmpeg \ |
| 52 | + git \ |
| 53 | + ssh \ |
| 54 | + tree \ |
| 55 | + && \ |
| 56 | + # Install python |
| 57 | + add-apt-repository ppa:deadsnakes/ppa && \ |
| 58 | + apt-get install -y \ |
| 59 | + python${PYTHON_VERSION} \ |
| 60 | + python${PYTHON_VERSION}-distutils \ |
| 61 | + python${PYTHON_VERSION}-dev \ |
| 62 | + && \ |
| 63 | + update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \ |
| 64 | + update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \ |
| 65 | + curl https://bootstrap.pypa.io/get-pip.py | python && \ |
| 66 | + # Cleaning |
| 67 | + apt-get autoremove -y && \ |
| 68 | + apt-get clean && \ |
| 69 | + rm -rf /root/.cache && \ |
| 70 | + rm -rf /var/lib/apt/lists/* |
| 71 | + |
| 72 | +ENV PYTHONPATH="/usr/lib/python${PYTHON_VERSION}/site-packages" |
| 73 | + |
| 74 | +COPY .actions/ .actions/ |
| 75 | +COPY requirements.txt . |
| 76 | +COPY _requirements/ _requirements/ |
| 77 | + |
| 78 | +RUN \ |
| 79 | + CUDA_VERSION_MM=${CUDA_VERSION%.*} && \ |
| 80 | + CU_VERSION_MM=${CUDA_VERSION_MM//'.'/''} && \ |
| 81 | + pip install --no-cache-dir -r requirements.txt \ |
| 82 | + --find-links "https://download.pytorch.org/whl/cu${CU_VERSION_MM}/torch_stable.html" && \ |
| 83 | + rm -rf requirements.txt .actions/ _requirements/ |
| 84 | + |
| 85 | +RUN \ |
| 86 | + # Show what we have |
| 87 | + pip --version && \ |
| 88 | + pip list && \ |
| 89 | + python -c "import sys; ver = sys.version_info ; assert f'{ver.major}.{ver.minor}' == '$PYTHON_VERSION', ver" && \ |
| 90 | + python -c "import torch; assert torch.__version__.startswith('$PYTORCH_VERSION'), torch.__version__" |
0 commit comments