Skip to content

Commit 60d8c89

Browse files
huydhnaws-kingrj
authored andcommitted
[CI] Update setup-linux to simplify compiler setup (pytorch#178361)
The logic has been moved to pytorch/test-infra#7879, so here we just need to choose the right compiler. Pull Request resolved: pytorch#178361 Approved by: https://github.com/atalman
1 parent cd0201b commit 60d8c89

1 file changed

Lines changed: 29 additions & 41 deletions

File tree

.github/actions/setup-linux/action.yml

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,14 @@ runs:
131131
if: ${{ inputs.use-arc == 'true' }}
132132
shell: bash
133133
run: |
134+
# Limit uv parallelism to avoid OOM on memory-constrained pods where
135+
# uv defaults to the host CPU count (e.g., 192) instead of the pod
136+
# limit. Can be removed once uv pip cache is ready
137+
export UV_CONCURRENT_BUILDS=1
134138
uv pip install -r .ci/docker/requirements-ci.txt
135139
echo "CMAKE_PREFIX_PATH=${VIRTUAL_ENV}" >> "${GITHUB_ENV}"
136140
137-
- name: Install C++ compiler
141+
- name: Activate C++ compiler
138142
if: ${{ inputs.use-arc == 'true' && inputs.compiler != '' }}
139143
shell: bash
140144
run: |
@@ -144,54 +148,38 @@ runs:
144148
CLANG_VERSION=$(echo "${COMPILER}" | perl -n -e'/^clang(\d+)$/ && print $1')
145149
GCC_VERSION=$(echo "${COMPILER}" | perl -n -e'/^gcc(\d+)$/ && print $1')
146150
151+
# Strip any gcc-toolset paths that might linger from the base image
152+
CLEAN_PATH=$(echo "${PATH}" | tr ':' '\n' | grep -v '/opt/rh/gcc-toolset-' | tr '\n' ':' | sed 's/:$//')
153+
CLEAN_LD_PATH=$(echo "${LD_LIBRARY_PATH:-}" | tr ':' '\n' | grep -v '/opt/rh/gcc-toolset-' | tr '\n' ':' | sed 's/:$//')
154+
147155
if [ -z "${CLANG_VERSION}" ] && [ -z "${GCC_VERSION}" ]; then
148156
echo "ERROR: unrecognized compiler '${COMPILER}', expected gcc<N> or clang<N>"
149157
exit 1
150158
elif [ -n "${CLANG_VERSION}" ]; then
151-
# Clang 20 and libomp-devel 20 are already installed in the base image.
152-
# For older versions (15, 18), download pre-built tarballs from S3.
153-
if [ "${CLANG_VERSION}" = "20" ]; then
154-
echo "Using base image default clang 20"
155-
elif [ "${CLANG_VERSION}" = "15" ] || [ "${CLANG_VERSION}" = "18" ]; then
156-
ARCH=$(uname -m)
157-
PLATFORM="linux-${ARCH}"
158-
S3_URL="https://gha-artifacts.s3.amazonaws.com/clang/${PLATFORM}/clang-${CLANG_VERSION}/clang-${CLANG_VERSION}-${PLATFORM}.tar.gz"
159-
INSTALL_DIR="/opt/clang-${CLANG_VERSION}"
160-
161-
echo "Downloading clang ${CLANG_VERSION} from ${S3_URL}"
162-
curl -fsSL "${S3_URL}" -o /tmp/clang.tar.gz
163-
mkdir -p "${INSTALL_DIR}"
164-
tar xzf /tmp/clang.tar.gz -C "${INSTALL_DIR}" --strip-components=1
165-
rm -f /tmp/clang.tar.gz
166-
167-
echo "PATH=${INSTALL_DIR}/bin:${PATH}" >> "${GITHUB_ENV}"
168-
echo "CC=${INSTALL_DIR}/bin/clang" >> "${GITHUB_ENV}"
169-
echo "CXX=${INSTALL_DIR}/bin/clang++" >> "${GITHUB_ENV}"
170-
echo "CMAKE_PREFIX_PATH=${INSTALL_DIR}:${CMAKE_PREFIX_PATH:-}" >> "${GITHUB_ENV}"
171-
else
172-
echo "ERROR: unsupported clang version '${CLANG_VERSION}', available: 15, 18, 20"
159+
# Clang versions are pre-installed in the base image under /opt/clang-{VERSION}.
160+
INSTALL_DIR="/opt/clang-${CLANG_VERSION}"
161+
if [ ! -d "${INSTALL_DIR}" ]; then
162+
echo "ERROR: clang ${CLANG_VERSION} not found at ${INSTALL_DIR}"
173163
exit 1
174164
fi
165+
echo "PATH=${INSTALL_DIR}/bin:${CLEAN_PATH}" >> "${GITHUB_ENV}"
166+
echo "LD_LIBRARY_PATH=${CLEAN_LD_PATH}" >> "${GITHUB_ENV}"
167+
echo "CC=${INSTALL_DIR}/bin/clang" >> "${GITHUB_ENV}"
168+
echo "CXX=${INSTALL_DIR}/bin/clang++" >> "${GITHUB_ENV}"
169+
echo "CMAKE_PREFIX_PATH=${INSTALL_DIR}:${CMAKE_PREFIX_PATH:-}" >> "${GITHUB_ENV}"
175170
else
176-
# On AlmaLinux 9, GCC 11 is the system default at /usr/bin/gcc.
177-
# Only install gcc-toolset for newer versions that aren't already available.
178-
if [ "${GCC_VERSION}" = "11" ]; then
179-
# Remove gcc/g++ from /usr/local/bin so they don't shadow /usr/bin/gcc (system default)
180-
rm -f /usr/local/bin/gcc /usr/local/bin/g++ /usr/local/bin/cc /usr/local/bin/c++
181-
# Strip any /opt/rh/gcc-toolset-* paths from PATH
182-
CLEAN_PATH=$(echo "${PATH}" | tr ':' '\n' | grep -v '/opt/rh/gcc-toolset-' | tr '\n' ':' | sed 's/:$//')
183-
echo "PATH=${CLEAN_PATH}" >> "${GITHUB_ENV}"
184-
echo "Using system default GCC 11"
185-
else
186-
dnf install -y \
187-
gcc-toolset-${GCC_VERSION}-gcc \
188-
gcc-toolset-${GCC_VERSION}-gcc-c++ \
189-
gcc-toolset-${GCC_VERSION}-gcc-gfortran
190-
191-
TOOLSET_ROOT="/opt/rh/gcc-toolset-${GCC_VERSION}/root/usr"
192-
echo "PATH=${TOOLSET_ROOT}/bin:${PATH}" >> "${GITHUB_ENV}"
193-
echo "LD_LIBRARY_PATH=${TOOLSET_ROOT}/lib64:${TOOLSET_ROOT}/lib:${LD_LIBRARY_PATH}" >> "${GITHUB_ENV}"
171+
# All GCC versions are pre-installed in the base image via gcc-toolset
172+
# under /opt/rh/gcc-toolset-{VERSION}. Remove /usr/local/bin compiler
173+
# symlinks from the manylinux base image so they don't shadow the
174+
# toolset we're activating.
175+
rm -f /usr/local/bin/gcc /usr/local/bin/g++ /usr/local/bin/cc /usr/local/bin/c++
176+
TOOLSET_ROOT="/opt/rh/gcc-toolset-${GCC_VERSION}/root/usr"
177+
if [ ! -d "${TOOLSET_ROOT}" ]; then
178+
echo "ERROR: gcc-toolset-${GCC_VERSION} not found at ${TOOLSET_ROOT}"
179+
exit 1
194180
fi
181+
echo "PATH=${TOOLSET_ROOT}/bin:${CLEAN_PATH}" >> "${GITHUB_ENV}"
182+
echo "LD_LIBRARY_PATH=${TOOLSET_ROOT}/lib64:${TOOLSET_ROOT}/lib:${CLEAN_LD_PATH}" >> "${GITHUB_ENV}"
195183
fi
196184
197185
- name: Switch CUDA version

0 commit comments

Comments
 (0)