|
| 1 | +ARG PY_VERSION |
| 2 | +ARG DOCKER_CUDA_VERSION=12.4.1 |
| 3 | +FROM nvidia/cuda:${DOCKER_CUDA_VERSION}-cudnn-devel-ubuntu22.04 |
| 4 | + |
| 5 | +ARG PY_VERSION |
| 6 | + |
| 7 | +# For A100, RTX4090, H100, and H200 |
| 8 | +ENV TORCH_CUDA_ARCH_LIST='7.0 7.5 8.0 8.6 8.9 9.0+PTX' |
| 9 | +ENV MAX_JOBS=2 |
| 10 | +ENV NVCC_THREADS=8 |
| 11 | + |
| 12 | +ENV DEBIAN_FRONTEND=noninteractive |
| 13 | +ENV CUDA_HOME=/usr/local/cuda |
| 14 | +ENV SETUPTOOLS_USE_DISTUTILS=stdlib |
| 15 | + |
| 16 | +RUN apt-get update -y |
| 17 | + |
| 18 | +# Utils |
| 19 | +RUN apt-get install -y vim git bzip2 tmux wget tar htop unzip |
| 20 | + |
| 21 | +# SSH |
| 22 | +RUN apt-get install -y ssh openssh-server |
| 23 | +RUN mkdir -p /var/run/sshd |
| 24 | +RUN echo "root:root" | chpasswd |
| 25 | +RUN echo "Port 22" >> /etc/ssh/sshd_config |
| 26 | +RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config |
| 27 | +EXPOSE 22 |
| 28 | + |
| 29 | +RUN apt-get update -y && apt-get install -y software-properties-common |
| 30 | +RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub |
| 31 | +RUN add-apt-repository -y "deb https://developer.download.nvidia.com/devtools/repos/ubuntu22.04/$(dpkg --print-architecture) /" |
| 32 | +RUN apt-get install -y nsight-systems-2024.6.2 |
| 33 | +RUN apt-get install -y mesa-utils x11-apps |
| 34 | +RUN apt-get install -y freeglut3-dev libglu1-mesa-dev mesa-common-dev libxkbfile-dev libgl1-mesa-glx |
| 35 | + |
| 36 | +ENV LIBGL_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri |
| 37 | +ENV LIBGL_ALWAYS_INDIRECT=1 |
| 38 | + |
| 39 | +# Build tools |
| 40 | +RUN rm /etc/apt/sources.list.d/archive_uri-https_developer_download_nvidia_com_devtools_repos_ubuntu22_04_amd64-jammy.list |
| 41 | +RUN apt-get update -y && apt-get install -y gcc-12 g++-12 ninja-build cmake build-essential autoconf libtool automake git |
| 42 | +RUN apt-get install -y ffmpeg libsm6 libxext6 libgl1 |
| 43 | + |
| 44 | +# Utils |
| 45 | +RUN apt-get install -y vim git bzip2 tmux wget tar htop curl |
| 46 | +RUN add-apt-repository ppa:deadsnakes/ppa && apt-get install -y python3.12 python3.12-dev python3.12-venv |
| 47 | + |
| 48 | +RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 |
| 49 | +RUN update-alternatives --set python3 /usr/bin/python3.12 |
| 50 | +RUN ln -sf /usr/bin/python3.12-config /usr/bin/python3-config |
| 51 | +RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12 |
| 52 | + |
| 53 | +RUN curl -LsSf https://astral.sh/uv/0.8.14/install.sh | sh |
| 54 | + |
| 55 | +SHELL ["/bin/bash", "-c"] |
| 56 | +ENV PATH=/root/.local/bin:$PATH |
| 57 | + |
| 58 | +RUN uv python pin ${PY_VERSION} |
| 59 | +RUN uv pip install --no-cache --system ipython tqdm rich jupyter jupyterlab ipykernel pandas einops safetensors pyyaml requests psutil opencv-python-headless matplotlib seaborn scikit-learn scipy pillow tensorboard h5py |
| 60 | + |
| 61 | +# torch installer |
| 62 | +COPY <<EOF /usr/local/bin/install_torch_env |
| 63 | +#!/bin/bash |
| 64 | +set -e |
| 65 | +TORCH_VER=\$1 |
| 66 | +VISION_VER=\$2 |
| 67 | +CUDA_VER=\$3 |
| 68 | +BASE_DIR=/ddiff-base/py\${PY_VERSION}-torch\${TORCH_VER} |
| 69 | +mkdir -p "\$BASE_DIR" && cd "\$BASE_DIR" |
| 70 | +uv venv --python "\${PY_VERSION}" --system-site-packages |
| 71 | +uv pip install --no-cache torch=="\${TORCH_VER}" torchvision=="\${VISION_VER}" torchaudio=="\${TORCH_VER}" --index-url "https://download.pytorch.org/whl/\${CUDA_VER}" |
| 72 | +echo "alias uv_init_torch\${TORCH_VER}='ln -sfn \${BASE_DIR}/.venv ./.venv && echo Created uv virtual environment with torch==\${TORCH_VER}'" >> ~/.bashrc |
| 73 | +EOF |
| 74 | +RUN chmod +x /usr/local/bin/install_torch_env |
| 75 | + |
| 76 | +# pytorch 2.4.1 (251209 Update) |
| 77 | +RUN install_torch_env 2.4.1 0.19.1 cu124 |
| 78 | + |
| 79 | +# pytorch 2.5.1 (251209 Update) |
| 80 | +RUN install_torch_env 2.5.1 0.20.1 cu124 |
| 81 | + |
| 82 | +# pytorch 2.6.0 (251209 Update) |
| 83 | +RUN install_torch_env 2.6.0 0.21.0 cu124 |
| 84 | + |
| 85 | +# pytorch 2.7.1 (251209 Update) |
| 86 | +RUN install_torch_env 2.7.1 0.22.1 cu126 |
| 87 | + |
| 88 | +# pytorch 2.9.0 (251209 Update) |
| 89 | +RUN install_torch_env 2.9.0 0.24.0 cu126 |
0 commit comments