Skip to content

Commit b2eb0e8

Browse files
seemethereatalman
authored andcommitted
docker: Use miniforge, install from pip (pytorch#134274)
Switch installation of the pytorch package to be installed from our download.pytorch.org sources which are better maintained. As well, switching over the miniconda installation to a miniforge installation in order to ensure backwards compat for users expecting to have the conda package manager installed. Pull Request resolved: pytorch#134274 Approved by: https://github.com/malfet, https://github.com/atalman Co-authored-by: atalman <[email protected]>
1 parent 30d7e7a commit b2eb0e8

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

.github/workflows/docker-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+$ ]]; then
111111
{
112112
echo "DOCKER_IMAGE=pytorch-test";
113-
echo "INSTALL_CHANNEL=pytorch-test";
113+
echo "INSTALL_CHANNEL=whl/test";
114114
echo "TRITON_VERSION=$(cut -f 1 .ci/docker/triton_version.txt)";
115115
} >> "${GITHUB_ENV}"
116116
fi
@@ -119,7 +119,7 @@ jobs:
119119
run: |
120120
{
121121
echo "DOCKER_IMAGE=pytorch-nightly";
122-
echo "INSTALL_CHANNEL=pytorch-nightly";
122+
echo "INSTALL_CHANNEL=whl/nightly";
123123
echo "TRITON_VERSION=$(cut -f 1 .ci/docker/triton_version.txt)+$(cut -c -10 .ci/docker/ci_commit_pins/triton.txt)";
124124
} >> "${GITHUB_ENV}"
125125
- name: Run docker build / push

Dockerfile

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN case ${TARGETPLATFORM} in \
3232
"linux/arm64") MINICONDA_ARCH=aarch64 ;; \
3333
*) MINICONDA_ARCH=x86_64 ;; \
3434
esac && \
35-
curl -fsSL -v -o ~/miniconda.sh -O "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-${MINICONDA_ARCH}.sh"
35+
curl -fsSL -v -o ~/miniconda.sh -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-${MINICONDA_ARCH}.sh"
3636
COPY requirements.txt .
3737
# Manually invoke bash on miniconda script per https://github.com/conda/conda/issues/10431
3838
RUN chmod +x ~/miniconda.sh && \
@@ -61,19 +61,19 @@ RUN --mount=type=cache,target=/opt/ccache \
6161

6262
FROM conda as conda-installs
6363
ARG PYTHON_VERSION=3.11
64-
ARG CUDA_VERSION=12.1
64+
ARG CUDA_PATH=cu121
6565
ARG CUDA_CHANNEL=nvidia
66-
ARG INSTALL_CHANNEL=pytorch-nightly
66+
ARG INSTALL_CHANNEL=whl/nightly
6767
# Automatically set by buildx
6868
RUN /opt/conda/bin/conda update -y -n base -c defaults conda
69-
RUN /opt/conda/bin/conda install -c "${INSTALL_CHANNEL}" -y python=${PYTHON_VERSION}
69+
RUN /opt/conda/bin/conda install -y python=${PYTHON_VERSION}
7070

7171
ARG TARGETPLATFORM
7272

73-
# On arm64 we can only install wheel packages.
73+
# INSTALL_CHANNEL whl - release, whl/nightly - nightly, whle/test - test channels
7474
RUN case ${TARGETPLATFORM} in \
7575
"linux/arm64") pip install --extra-index-url https://download.pytorch.org/whl/cpu/ torch torchvision torchaudio ;; \
76-
*) /opt/conda/bin/conda install -c "${INSTALL_CHANNEL}" -c "${CUDA_CHANNEL}" -y "python=${PYTHON_VERSION}" pytorch torchvision torchaudio "pytorch-cuda=$(echo $CUDA_VERSION | cut -d'.' -f 1-2)" ;; \
76+
*) pip install --index-url https://download.pytorch.org/${INSTALL_CHANNEL}/${CUDA_PATH#.}/ torch torchvision torchaudio ;; \
7777
esac && \
7878
/opt/conda/bin/conda clean -ya
7979
RUN /opt/conda/bin/pip install torchelastic

docker.Makefile

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ CMAKE_VARS ?=
1818
# The conda channel to use to install cudatoolkit
1919
CUDA_CHANNEL = nvidia
2020
# The conda channel to use to install pytorch / torchvision
21-
INSTALL_CHANNEL ?= pytorch
21+
INSTALL_CHANNEL ?= whl
22+
23+
CUDA_PATH ?= cpu
24+
ifneq ("$(CUDA_VERSION_SHORT)","cpu")
25+
CUDA_PATH = cu$(subst .,,$(CUDA_VERSION_SHORT))
26+
endif
2227

2328
PYTHON_VERSION ?= 3.11
2429
# Match versions that start with v followed by a number, to avoid matching with tags like ciflow
@@ -31,7 +36,7 @@ TRITON_VERSION ?=
3136
BUILD_ARGS = --build-arg BASE_IMAGE=$(BASE_IMAGE) \
3237
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
3338
--build-arg CUDA_VERSION=$(CUDA_VERSION) \
34-
--build-arg CUDA_CHANNEL=$(CUDA_CHANNEL) \
39+
--build-arg CUDA_PATH=$(CUDA_PATH) \
3540
--build-arg PYTORCH_VERSION=$(PYTORCH_VERSION) \
3641
--build-arg INSTALL_CHANNEL=$(INSTALL_CHANNEL) \
3742
--build-arg TRITON_VERSION=$(TRITON_VERSION) \

0 commit comments

Comments
 (0)