Skip to content

Commit 7b60120

Browse files
clee2000amathewc
authored andcommitted
[ci][anaconda] Remove conda from linter docker images (pytorch#147789)
Remove conda usage from the linter docker images Handles part of pytorch#148110 Pull Request resolved: pytorch#147789 Approved by: https://github.com/atalman
1 parent f7db51c commit 7b60120

File tree

7 files changed

+45
-50
lines changed

7 files changed

+45
-50
lines changed

.ci/docker/build.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,13 @@ case "$image" in
382382
# TODO: Use 3.9 here because of this issue https://github.com/python/mypy/issues/13627.
383383
# We will need to update mypy version eventually, but that's for another day. The task
384384
# would be to upgrade mypy to 1.0.0 with Python 3.11
385-
ANACONDA_PYTHON_VERSION=3.9
386-
CONDA_CMAKE=yes
385+
PYTHON_VERSION=3.9
386+
PIP_CMAKE=yes
387387
;;
388388
pytorch-linux-jammy-cuda11.8-cudnn9-py3.9-linter)
389-
ANACONDA_PYTHON_VERSION=3.9
389+
PYTHON_VERSION=3.9
390390
CUDA_VERSION=11.8
391-
CONDA_CMAKE=yes
391+
PIP_CMAKE=yes
392392
;;
393393
pytorch-linux-jammy-aarch64-py3.10-gcc11)
394394
ANACONDA_PYTHON_VERSION=3.10
@@ -478,6 +478,7 @@ docker build \
478478
--build-arg "GLIBC_VERSION=${GLIBC_VERSION}" \
479479
--build-arg "CLANG_VERSION=${CLANG_VERSION}" \
480480
--build-arg "ANACONDA_PYTHON_VERSION=${ANACONDA_PYTHON_VERSION}" \
481+
--build-arg "PYTHON_VERSION=${PYTHON_VERSION}" \
481482
--build-arg "GCC_VERSION=${GCC_VERSION}" \
482483
--build-arg "CUDA_VERSION=${CUDA_VERSION}" \
483484
--build-arg "CUDNN_VERSION=${CUDNN_VERSION}" \
@@ -494,6 +495,7 @@ docker build \
494495
--build-arg "UCX_COMMIT=${UCX_COMMIT}" \
495496
--build-arg "UCC_COMMIT=${UCC_COMMIT}" \
496497
--build-arg "CONDA_CMAKE=${CONDA_CMAKE}" \
498+
--build-arg "PIP_CMAKE=${PIP_CMAKE}" \
497499
--build-arg "TRITON=${TRITON}" \
498500
--build-arg "TRITON_CPU=${TRITON_CPU}" \
499501
--build-arg "ONNX=${ONNX}" \

.ci/docker/common/install_linter.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
set -ex
44

5-
source "$(dirname "${BASH_SOURCE[0]}")/common_utils.sh"
6-
75
if [ -n "${UBUNTU_VERSION}" ]; then
86
apt update
97
apt-get install -y clang doxygen git graphviz nodejs npm libtinfo5
@@ -15,8 +13,8 @@ chown -R jenkins pytorch
1513

1614
pushd pytorch
1715
# Install all linter dependencies
18-
pip_install -r requirements.txt
19-
conda_run lintrunner init
16+
pip install -r requirements.txt
17+
lintrunner init
2018

2119
# Cache .lintbin directory as part of the Docker image
2220
cp -r .lintbin /tmp
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
apt-get update
5+
# Use deadsnakes in case we need an older python version
6+
sudo add-apt-repository ppa:deadsnakes/ppa
7+
apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python3-pip python${PYTHON_VERSION}-venv
8+
9+
# Use a venv because uv and some other package managers don't support --user install
10+
ln -s /usr/bin/python${PYTHON_VERSION} /usr/bin/python
11+
python -m venv /var/lib/jenkins/ci_env
12+
source /var/lib/jenkins/ci_env/bin/activate
13+
14+
python -mpip install --upgrade pip
15+
python -mpip install -r /opt/requirements-ci.txt
16+
if [ -n "${PIP_CMAKE}" ]; then
17+
python -mpip install cmake==3.31.6
18+
fi

.ci/docker/linter-cuda/Dockerfile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ COPY ./common/install_user.sh install_user.sh
1818
RUN bash ./install_user.sh && rm install_user.sh
1919

2020
# Install conda and other packages (e.g., numpy, pytest)
21-
ARG ANACONDA_PYTHON_VERSION
22-
ARG CONDA_CMAKE
23-
ENV ANACONDA_PYTHON_VERSION=$ANACONDA_PYTHON_VERSION
24-
ENV PATH /opt/conda/envs/py_$ANACONDA_PYTHON_VERSION/bin:/opt/conda/bin:$PATH
25-
COPY requirements-ci.txt /opt/conda/requirements-ci.txt
26-
COPY ./common/install_conda.sh install_conda.sh
27-
COPY ./common/common_utils.sh common_utils.sh
28-
COPY ./common/install_magma_conda.sh install_magma_conda.sh
29-
RUN bash ./install_conda.sh && rm install_conda.sh install_magma_conda.sh common_utils.sh /opt/conda/requirements-ci.txt
21+
ARG PYTHON_VERSION
22+
ARG PIP_CMAKE
23+
# Put venv into the env vars so users don't need to activate it
24+
ENV PATH /var/lib/jenkins/ci_env/bin:$PATH
25+
ENV VIRTUAL_ENV /var/lib/jenkins/ci_env
26+
COPY requirements-ci.txt /opt/requirements-ci.txt
27+
COPY ./common/install_python.sh install_python.sh
28+
RUN bash ./install_python.sh && rm install_python.sh /opt/requirements-ci.txt
3029

3130
# Install cuda and cudnn
3231
ARG CUDA_VERSION
@@ -37,9 +36,10 @@ ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:$PATH
3736

3837
# Note that Docker build forbids copying file outside the build context
3938
COPY ./common/install_linter.sh install_linter.sh
40-
COPY ./common/common_utils.sh common_utils.sh
4139
RUN bash ./install_linter.sh
42-
RUN rm install_linter.sh common_utils.sh
40+
RUN rm install_linter.sh
41+
42+
RUN chown -R jenkins:jenkins /var/lib/jenkins/ci_env
4343

4444
USER jenkins
4545
CMD ["bash"]

.ci/docker/linter/Dockerfile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@ COPY ./common/install_user.sh install_user.sh
1515
RUN bash ./install_user.sh && rm install_user.sh
1616

1717
# Install conda and other packages (e.g., numpy, pytest)
18-
ARG ANACONDA_PYTHON_VERSION
19-
ARG CONDA_CMAKE
20-
ENV ANACONDA_PYTHON_VERSION=$ANACONDA_PYTHON_VERSION
21-
ENV PATH /opt/conda/envs/py_$ANACONDA_PYTHON_VERSION/bin:/opt/conda/bin:$PATH
22-
COPY requirements-ci.txt /opt/conda/requirements-ci.txt
23-
COPY ./common/install_conda.sh install_conda.sh
24-
COPY ./common/common_utils.sh common_utils.sh
25-
RUN bash ./install_conda.sh && rm install_conda.sh common_utils.sh /opt/conda/requirements-ci.txt
18+
ARG PYTHON_VERSION
19+
ARG PIP_CMAKE
20+
ENV PATH /var/lib/jenkins/ci_env/bin:$PATH
21+
ENV VIRTUAL_ENV /var/lib/jenkins/ci_env
22+
COPY requirements-ci.txt /opt/requirements-ci.txt
23+
COPY ./common/install_python.sh install_python.sh
24+
RUN bash ./install_python.sh && rm install_python.sh /opt/requirements-ci.txt
2625

2726
# Note that Docker build forbids copying file outside the build context
2827
COPY ./common/install_linter.sh install_linter.sh
29-
COPY ./common/common_utils.sh common_utils.sh
3028
RUN bash ./install_linter.sh
31-
RUN rm install_linter.sh common_utils.sh
29+
RUN rm install_linter.sh
3230

3331
USER jenkins
3432
CMD ["bash"]

.github/scripts/lintrunner.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
#!/usr/bin/env bash
22
set -ex
33

4-
# The generic Linux job chooses to use base env, not the one setup by the image
5-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
6-
eval "$(command conda 'shell.bash' 'hook' 2> /dev/null)"
7-
conda activate "${CONDA_ENV}"
8-
94
# Use uv to speed up lintrunner init
105
python3 -m pip install uv==0.1.45
116

.github/workflows/lint.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ jobs:
6868
fetch-depth: 0
6969
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
7070
script: |
71-
# The generic Linux job chooses to use base env, not the one setup by the image
72-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
73-
conda activate "${CONDA_ENV}"
74-
7571
# Ensure no non-breaking spaces
7672
# NB: We use 'printf' below rather than '\u000a' since bash pre-4.2
7773
# does not support the '\u000a' syntax (which is relevant for local linters)
@@ -126,10 +122,6 @@ jobs:
126122
submodules: true
127123
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
128124
script: |
129-
# The generic Linux job chooses to use base env, not the one setup by the image
130-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
131-
conda activate "${CONDA_ENV}"
132-
133125
# Regenerate workflows
134126
.github/scripts/generate_ci_workflows.py
135127
@@ -163,10 +155,6 @@ jobs:
163155
fetch-depth: 0
164156
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
165157
script: |
166-
# The generic Linux job chooses to use base env, not the one setup by the image
167-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
168-
conda activate "${CONDA_ENV}"
169-
170158
# Regenerate ToCs and check that they didn't change
171159
set -eu
172160
@@ -203,10 +191,6 @@ jobs:
203191
fetch-depth: 0
204192
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
205193
script: |
206-
# The generic Linux job chooses to use base env, not the one setup by the image
207-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
208-
conda activate "${CONDA_ENV}"
209-
210194
# Test tools
211195
PYTHONPATH=$(pwd) pytest tools/stats
212196
PYTHONPATH=$(pwd) pytest tools/test -o "python_files=test*.py"

0 commit comments

Comments
 (0)