From a694a536fe38d44e941e64f2ca4241db64e70f46 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Thu, 3 Sep 2026 13:19:21 +0530 Subject: [PATCH 1/9] Added 2 scritps --- f/faiss/build_info.json | 13 +- f/faiss/faiss_v1.9.0_ubi_8.10.sh | 218 +++++++++++++++++++++++++++++++ f/faiss/faiss_v1.9.0_ubi_9.8.sh | 193 +++++++++++++++++++++++++++ 3 files changed, 420 insertions(+), 4 deletions(-) create mode 100644 f/faiss/faiss_v1.9.0_ubi_8.10.sh create mode 100644 f/faiss/faiss_v1.9.0_ubi_9.8.sh diff --git a/f/faiss/build_info.json b/f/faiss/build_info.json index 9ea1ab3450..9f0b32dc88 100644 --- a/f/faiss/build_info.json +++ b/f/faiss/build_info.json @@ -1,16 +1,21 @@ { - "maintainer": "Madhur-iiitd", + "maintainer": "amitkumar282", "package_name": "faiss", "github_url": "https://github.com/facebookresearch/faiss.git", - "version": "1.12.0", + "version": "1.9.0", "default_branch": "main", "build_script": "faiss_1.12_ubi.sh", "package_dir": "f/faiss", - "docker_build": true, + "docker_build": false, "validate_build_script": true, "use_non_root_user": false, "wheel_build": true, - + "1.9.0": { + "build_script": [ + "faiss_v1.9.0_ubi_8.10.sh", + "faiss_v1.9.0_ubi_9.8.sh" + ] + }, "*": { "build_script": "faiss_1.12_ubi.sh" } diff --git a/f/faiss/faiss_v1.9.0_ubi_8.10.sh b/f/faiss/faiss_v1.9.0_ubi_8.10.sh new file mode 100644 index 0000000000..3ea4e0094c --- /dev/null +++ b/f/faiss/faiss_v1.9.0_ubi_8.10.sh @@ -0,0 +1,218 @@ +#!/bin/bash -ex +# ---------------------------------------------------------------------------- +# Package : faiss +# Version : v1.9.0 +# Source repo : https://github.com/facebookresearch/faiss.git +# Tested on : UBI 8.10 +# Language : C++ +# Ci-Check : true +# Maintainer : Amit Kumar +# Script License : Apache License, Version 2.0 or later +# +# Disclaimer : This script has been tested in root mode on the specified +# platform and package version. Functionality with newer +# versions of the package or OS is not guaranteed. +# ---------------------------------------------------------------------------- + +# Configuration +PACKAGE_NAME="faiss" +PACKAGE_ORG="facebookresearch" +PACKAGE_VERSION="v1.9.0" +PACKAGE_URL="https://github.com/${PACKAGE_ORG}/${PACKAGE_NAME}.git" +BUILD_HOME=$(pwd) +PACKAGE_DIR=faiss/python + +# ---------------------------------------------------------------------------- +# Install repositories and dependencies +# ---------------------------------------------------------------------------- + +# Remove stale CentOS Linux 8 / vault.centos.org repo files if present. +find /etc/yum.repos.d/ -maxdepth 1 -name "*.repo" \ + ! -name "ubi.repo" \ + ! -name "redhat.repo" \ + ! -name "almalinux8.repo" \ + -delete 2>/dev/null || true + +# Enable UBI repos already present in the UBI 8 container. +dnf install -y dnf-plugins-core + +dnf config-manager \ + --set-enabled \ + ubi-8-baseos-rpms \ + ubi-8-appstream-rpms \ + ubi-8-codeready-builder-rpms 2>/dev/null || true + +# Add AlmaLinux 8 repositories for packages not available in UBI. +cat > /etc/yum.repos.d/almalinux8.repo << 'EOF' +[al8-baseos] +name=AlmaLinux 8 - BaseOS +baseurl=https://repo.almalinux.org/almalinux/8/BaseOS/ppc64le/os/ +gpgcheck=0 +enabled=1 +excludepkgs=almalinux-release* almalinux-repos* almalinux-gpg-keys* + +[al8-appstream] +name=AlmaLinux 8 - AppStream +baseurl=https://repo.almalinux.org/almalinux/8/AppStream/ppc64le/os/ +gpgcheck=0 +enabled=1 +excludepkgs=almalinux-release* almalinux-repos* almalinux-gpg-keys* + +[al8-powertools] +name=AlmaLinux 8 - PowerTools +baseurl=https://repo.almalinux.org/almalinux/8/PowerTools/ppc64le/os/ +gpgcheck=0 +enabled=1 +excludepkgs=almalinux-release* almalinux-repos* almalinux-gpg-keys* +EOF + +# EPEL for any remaining dependencies. +# Avoid the dependency chain that conflicts with redhat-release on UBI 8. +if ! rpm -q epel-release &>/dev/null; then + EPEL_RPM=$(mktemp /tmp/epel-release-XXXXXX.rpm) + + curl -fsSL \ + -o "$EPEL_RPM" \ + https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + + rpm -ivh --nodeps --noscripts "$EPEL_RPM" + + rm -f "$EPEL_RPM" +fi + +dnf install -y git gcc-toolset-11 cmake file lapack-devel python3.11-devel python3.11-pip python3.11-pytest python3.11-wheel pkg-config swig + +# ---------------------------------------------------------------------------- +# Build and install OpenBLAS +# ---------------------------------------------------------------------------- + +cd "$BUILD_HOME" +rm -rf OpenBLAS +git clone --branch v0.3.34 --depth 1 https://github.com/OpenMathLib/OpenBLAS +cd OpenBLAS + +make -j"$(nproc)" libs shared +make PREFIX=/usr/local install + +# Make /usr/local/lib visible to the runtime linker. +echo "/usr/local/lib" > /etc/ld.so.conf.d/openblas.conf +ldconfig + +# Verify OpenBLAS is available. +ldconfig -p | grep openblas + +# Enable GCC Toolset 11 +source /opt/rh/gcc-toolset-11/enable + +# Build and install gflags +cd "$BUILD_HOME" +rm -rf gflags +git clone --branch v2.3.0 --depth 1 https://github.com/gflags/gflags.git +cd gflags +mkdir build +cd build +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/opt/gflags-2.3.0 \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_STATIC_LIBS=OFF \ + -DBUILD_TESTING=OFF + +make -j"$(nproc)" +make install + +# Install Python dependencies +pip3.11 install --prefer-binary scipy numpy==1.26.4 swig auditwheel patchelf --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux + +mkdir -p ~/.local/bin +ln -sf /usr/bin/python3.11 ~/.local/bin/python +ln -sf /usr/bin/python3.11 ~/.local/bin/python3 + +export PATH="$HOME/.local/bin:$PATH" + +# Clone FAISS +cd "$BUILD_HOME" +rm -rf "$PACKAGE_NAME" +git clone "$PACKAGE_URL" -b "$PACKAGE_VERSION" +cd "$PACKAGE_NAME" + +# Build FAISS +mkdir build +cd build +cmake \ + -DFAISS_ENABLE_GPU=OFF \ + -DFAISS_ENABLE_PYTHON=ON \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_TESTING=ON \ + -DFAISS_ENABLE_C_API=ON \ + -DCMAKE_BUILD_TYPE=Release \ + .. + +ret=0 +make -j"$(nproc)" || ret=$? + +if [ "$ret" -ne 0 ]; then + echo "FAIL: ${PACKAGE_NAME} Build failed." + exit 1 +fi + +# Verify native libraries +file faiss/libfaiss.so +file faiss/python/_swigfaiss.so + +# Run FAISS C++ tests +ret=0 +make test || ret=$? + +if [ "$ret" -ne 0 ]; then + echo "FAIL: ${PACKAGE_NAME} C++ tests failed." + exit 2 +fi + +# Build Python wheel +cd faiss/python +rm -rf wheelhouse +mkdir -p wheelhouse/raw + +python3.11 -m pip wheel . -w wheelhouse/raw +WHEEL_VERSION="${PACKAGE_VERSION#v}" +RAW_WHEEL=$(find wheelhouse/raw -maxdepth 1 -name "faiss-${WHEEL_VERSION}-*.whl" -print -quit) + +if [ -z "$RAW_WHEEL" ]; then + echo "FAIL: Python wheel was not generated." + exit 1 +fi + +# Repair wheel +# Bundle libfaiss.so and other required shared libraries and generate a platform-specific ppc64le wheel. +auditwheel repair "$RAW_WHEEL" -w wheelhouse +rm -f "$RAW_WHEEL" +REPAIRED_WHEEL=$(find wheelhouse -maxdepth 1 -name "faiss-${WHEEL_VERSION}-*.whl" -print -quit) + +if [ -z "$REPAIRED_WHEEL" ]; then + echo "FAIL: Repaired Python wheel was not generated." + exit 1 +fi + +# Install repaired wheel +python3.11 -m pip install --force-reinstall "$REPAIRED_WHEEL" +python3.11 -m pip install \ + --force-reinstall \ + --no-deps \ + --only-binary=:all: \ + --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ + "numpy==1.26.4" + +# Python tests +cd "$BUILD_HOME/$PACKAGE_NAME" +ret=0 +python3.11 -m pytest ./tests/test_*.py -v || ret=$? + +if [ "$ret" -ne 0 ]; then + echo "FAIL: ${PACKAGE_NAME} python tests failed." + exit 2 +fi + +# Conclude +set +ex +echo "Build and tests complete!" diff --git a/f/faiss/faiss_v1.9.0_ubi_9.8.sh b/f/faiss/faiss_v1.9.0_ubi_9.8.sh new file mode 100644 index 0000000000..83f8ac33ed --- /dev/null +++ b/f/faiss/faiss_v1.9.0_ubi_9.8.sh @@ -0,0 +1,193 @@ +#!/bin/bash -ex +# ---------------------------------------------------------------------------- +# Package : faiss +# Version : v1.9.0 +# Source repo : https://github.com/facebookresearch/faiss.git +# Tested on : UBI 9.8 +# Language : C++ +# Ci-Check : true +# Maintainer : Amit Kumar +# Script License : Apache License, Version 2.0 or later +# +# Disclaimer : This script has been tested in root mode on the specified +# platform and package version. Functionality with newer +# versions of the package or OS is not guaranteed. +# ---------------------------------------------------------------------------- + +# Configuration +PACKAGE_NAME="faiss" +PACKAGE_ORG="facebookresearch" +PACKAGE_VERSION="v1.9.0" +PACKAGE_URL="https://github.com/${PACKAGE_ORG}/${PACKAGE_NAME}.git" +BUILD_HOME=$(pwd) +PACKAGE_DIR=faiss/python + +# ---------------------------------------------------------------------------- +# Install repositories and dependencies +# ---------------------------------------------------------------------------- + +# Remove stale CentOS Linux 8 / vault.centos.org repo files if present. +find /etc/yum.repos.d/ -maxdepth 1 -name "*.repo" \ + ! -name "ubi.repo" \ + ! -name "redhat.repo" \ + ! -name "almalinux9.repo" \ + -delete 2>/dev/null || true + +# AlmaLinux 9 is ABI-compatible with RHEL 9 and fully supports ppc64le. +cat > /etc/yum.repos.d/almalinux9.repo << 'EOF' +[al9-baseos] +name=AlmaLinux 9 - BaseOS +baseurl=https://repo.almalinux.org/almalinux/9/BaseOS/ppc64le/os/ +gpgcheck=0 +enabled=1 + +[al9-appstream] +name=AlmaLinux 9 - AppStream +baseurl=https://repo.almalinux.org/almalinux/9/AppStream/ppc64le/os/ +gpgcheck=0 +enabled=1 + +[al9-crb] +name=AlmaLinux 9 - CRB +baseurl=https://repo.almalinux.org/almalinux/9/CRB/ppc64le/os/ +gpgcheck=0 +enabled=1 +EOF + +dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm +dnf install -y git gcc gcc-c++ cmake file lapack-devel-3.9.0-8.el9.ppc64le swig python3.11-devel python3.11-pip python3.11-pytest python3.11-wheel + +pip3.11 install --prefer-binary scipy numpy==1.26.4 auditwheel patchelf --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux + +mkdir -p ~/.local/bin +ln -sf /usr/bin/python3.11 ~/.local/bin/python +ln -sf /usr/bin/python3.11 ~/.local/bin/python3 +export PATH="$HOME/.local/bin:$PATH" + +# ---------------------------------------------------------------------------- +# Build and install OpenBLAS +# ---------------------------------------------------------------------------- + +cd "$BUILD_HOME" +git clone https://github.com/OpenMathLib/OpenBLAS +cd OpenBLAS +git checkout v0.3.29 + +make -j"$(nproc)" TARGET=POWER8 DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=0 NUM_THREADS=20 NO_AFFINITY=1 +make install + +# ---------------------------------------------------------------------------- +# Build and install gflags +# ---------------------------------------------------------------------------- + +cd "$BUILD_HOME" +git clone --branch v2.3.0 --depth 1 https://github.com/gflags/gflags.git +cd gflags +mkdir build +cd build + +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/opt/gflags-2.3.0 \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_STATIC_LIBS=OFF \ + -DBUILD_TESTING=OFF + +make -j"$(nproc)" +make install + +# ---------------------------------------------------------------------------- +# Clone FAISS +# ---------------------------------------------------------------------------- + +cd "$BUILD_HOME" +rm -rf "$PACKAGE_NAME" +git clone "$PACKAGE_URL" -b "$PACKAGE_VERSION" +cd "$PACKAGE_NAME" + +# ---------------------------------------------------------------------------- +# Build FAISS +# ---------------------------------------------------------------------------- + +mkdir build +cd build + +cmake \ + -DFAISS_ENABLE_GPU=OFF \ + -DFAISS_ENABLE_PYTHON=ON \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_TESTING=ON \ + -DFAISS_ENABLE_C_API=ON \ + -DCMAKE_BUILD_TYPE=Release \ + .. + +ret=0 +make -j"$(nproc)" || ret=$? + +if [ "$ret" -ne 0 ]; then + echo "FAIL: ${PACKAGE_NAME} Build failed." + exit 1 +fi + +# Verify native libraries +file faiss/libfaiss.so +file faiss/python/_swigfaiss.so + +# Run FAISS C++ tests +ret=0 +make test || ret=$? + +if [ "$ret" -ne 0 ]; then + echo "FAIL: ${PACKAGE_NAME} C++ tests failed." + exit 2 +fi + +# ---------------------------------------------------------------------------- +# Build Python wheel +# ---------------------------------------------------------------------------- + +cd "$PACKAGE_DIR" +rm -rf dist wheelhouse +mkdir -p dist wheelhouse + +python3.11 -m pip wheel . -w dist + +WHEEL_VERSION="${PACKAGE_VERSION#v}" +RAW_WHEEL=$(find dist -maxdepth 1 -name "faiss-${WHEEL_VERSION}-*.whl" -print -quit) + +if [ -z "$RAW_WHEEL" ]; then + echo "FAIL: Python wheel was not generated." + exit 1 +fi + +# Repair wheel +# Bundle required shared libraries and generate a ppc64le wheel. +auditwheel repair "$RAW_WHEEL" -w wheelhouse + +REPAIRED_WHEEL=$(find wheelhouse -maxdepth 1 -name "faiss-${WHEEL_VERSION}-*.whl" -print -quit) + +if [ -z "$REPAIRED_WHEEL" ]; then + echo "FAIL: Repaired Python wheel was not generated." + exit 1 +fi + +# Install repaired wheel +python3.11 -m pip install --force-reinstall "$REPAIRED_WHEEL" + +# ---------------------------------------------------------------------------- +# Python tests +# ---------------------------------------------------------------------------- + +cd "$BUILD_HOME/$PACKAGE_NAME" + +ret=0 +python3.11 -m pytest ./tests/test_*.py -v || ret=$? + +if [ "$ret" -ne 0 ]; then + echo "FAIL: ${PACKAGE_NAME} Python tests failed." + exit 2 +fi + +# Conclude +set +ex +echo "Build and tests complete!" From 405d3be97c73e84bc2f47ce82dec04b08a69a587 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Thu, 3 Sep 2026 14:08:17 +0530 Subject: [PATCH 2/9] Resolved CI Issues related with lapack-devel --- f/faiss/faiss_v1.9.0_ubi_8.10.sh | 188 +++++++++++++++++++++++++++---- f/faiss/faiss_v1.9.0_ubi_9.8.sh | 186 +++++++++++++++++++++++++----- 2 files changed, 320 insertions(+), 54 deletions(-) diff --git a/f/faiss/faiss_v1.9.0_ubi_8.10.sh b/f/faiss/faiss_v1.9.0_ubi_8.10.sh index 3ea4e0094c..d7440c728d 100644 --- a/f/faiss/faiss_v1.9.0_ubi_8.10.sh +++ b/f/faiss/faiss_v1.9.0_ubi_8.10.sh @@ -20,13 +20,14 @@ PACKAGE_ORG="facebookresearch" PACKAGE_VERSION="v1.9.0" PACKAGE_URL="https://github.com/${PACKAGE_ORG}/${PACKAGE_NAME}.git" BUILD_HOME=$(pwd) -PACKAGE_DIR=faiss/python +SCRIPT_PATH=$(dirname "$(realpath "$0")") # ---------------------------------------------------------------------------- # Install repositories and dependencies # ---------------------------------------------------------------------------- -# Remove stale CentOS Linux 8 / vault.centos.org repo files if present. +# Remove any stale CentOS Linux 8 / vault.centos.org repo files that may be +# baked into the base image and cause timeout failures at metadata fetch time. find /etc/yum.repos.d/ -maxdepth 1 -name "*.repo" \ ! -name "ubi.repo" \ ! -name "redhat.repo" \ @@ -43,6 +44,7 @@ dnf config-manager \ ubi-8-codeready-builder-rpms 2>/dev/null || true # Add AlmaLinux 8 repositories for packages not available in UBI. +# AlmaLinux 8 is ABI-compatible with RHEL 8 and supports ppc64le. cat > /etc/yum.repos.d/almalinux8.repo << 'EOF' [al8-baseos] name=AlmaLinux 8 - BaseOS @@ -67,7 +69,8 @@ excludepkgs=almalinux-release* almalinux-repos* almalinux-gpg-keys* EOF # EPEL for any remaining dependencies. -# Avoid the dependency chain that conflicts with redhat-release on UBI 8. +# Use rpm --nodeps --noscripts to avoid the epel-release -> almalinux-release +# dependency chain that conflicts with redhat-release on UBI 8. if ! rpm -q epel-release &>/dev/null; then EPEL_RPM=$(mktemp /tmp/epel-release-XXXXXX.rpm) @@ -80,18 +83,37 @@ if ! rpm -q epel-release &>/dev/null; then rm -f "$EPEL_RPM" fi -dnf install -y git gcc-toolset-11 cmake file lapack-devel python3.11-devel python3.11-pip python3.11-pytest python3.11-wheel pkg-config swig +dnf install -y \ + git \ + gcc-toolset-11 \ + cmake \ + file \ + lapack-devel \ + python3.11-devel \ + python3.11-pip \ + pkg-config \ + swig # ---------------------------------------------------------------------------- # Build and install OpenBLAS # ---------------------------------------------------------------------------- cd "$BUILD_HOME" + rm -rf OpenBLAS -git clone --branch v0.3.34 --depth 1 https://github.com/OpenMathLib/OpenBLAS + +git clone https://github.com/OpenMathLib/OpenBLAS cd OpenBLAS +git checkout v0.3.34 -make -j"$(nproc)" libs shared +# Build libraries and shared objects without running the OpenBLAS test suite. +ret=0 +make -j"$(nproc)" libs || ret=$? +if [ "$ret" -ne 0 ]; then + echo "FAIL: OpenBLAS build failed." + exit 1 +fi +make -j"$(nproc)" shared make PREFIX=/usr/local install # Make /usr/local/lib visible to the runtime linker. @@ -101,16 +123,29 @@ ldconfig # Verify OpenBLAS is available. ldconfig -p | grep openblas -# Enable GCC Toolset 11 +# ---------------------------------------------------------------------------- +# Enable GCC Toolset +# ---------------------------------------------------------------------------- + source /opt/rh/gcc-toolset-11/enable +# ---------------------------------------------------------------------------- # Build and install gflags +# ---------------------------------------------------------------------------- + cd "$BUILD_HOME" + rm -rf gflags -git clone --branch v2.3.0 --depth 1 https://github.com/gflags/gflags.git + +git clone \ + --branch v2.3.0 \ + --depth 1 \ + https://github.com/gflags/gflags.git + cd gflags mkdir build cd build + cmake .. \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/opt/gflags-2.3.0 \ @@ -118,27 +153,55 @@ cmake .. \ -DBUILD_STATIC_LIBS=OFF \ -DBUILD_TESTING=OFF -make -j"$(nproc)" +ret=0 +make -j"$(nproc)" || ret=$? +if [ "$ret" -ne 0 ]; then + echo "FAIL: gflags build failed." + exit 1 +fi make install +# ---------------------------------------------------------------------------- # Install Python dependencies -pip3.11 install --prefer-binary scipy numpy==1.26.4 swig auditwheel patchelf --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux +# ---------------------------------------------------------------------------- + +pip3.11 install \ + --prefer-binary \ + pytest \ + wheel \ + scipy \ + numpy==1.26.4 \ + swig \ + auditwheel \ + patchelf \ + --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux mkdir -p ~/.local/bin + ln -sf /usr/bin/python3.11 ~/.local/bin/python ln -sf /usr/bin/python3.11 ~/.local/bin/python3 export PATH="$HOME/.local/bin:$PATH" +# ---------------------------------------------------------------------------- # Clone FAISS +# ---------------------------------------------------------------------------- + cd "$BUILD_HOME" + rm -rf "$PACKAGE_NAME" + git clone "$PACKAGE_URL" -b "$PACKAGE_VERSION" + cd "$PACKAGE_NAME" +# ---------------------------------------------------------------------------- # Build FAISS +# ---------------------------------------------------------------------------- + mkdir build cd build + cmake \ -DFAISS_ENABLE_GPU=OFF \ -DFAISS_ENABLE_PYTHON=ON \ @@ -152,50 +215,109 @@ ret=0 make -j"$(nproc)" || ret=$? if [ "$ret" -ne 0 ]; then - echo "FAIL: ${PACKAGE_NAME} Build failed." + echo "FAIL: Build failed." exit 1 fi +# ---------------------------------------------------------------------------- # Verify native libraries +# ---------------------------------------------------------------------------- + file faiss/libfaiss.so file faiss/python/_swigfaiss.so +# ---------------------------------------------------------------------------- # Run FAISS C++ tests +# ---------------------------------------------------------------------------- + ret=0 make test || ret=$? - if [ "$ret" -ne 0 ]; then - echo "FAIL: ${PACKAGE_NAME} C++ tests failed." + echo "FAIL: C++ tests failed." exit 2 fi +# ---------------------------------------------------------------------------- # Build Python wheel +# ---------------------------------------------------------------------------- + cd faiss/python + rm -rf wheelhouse mkdir -p wheelhouse/raw -python3.11 -m pip wheel . -w wheelhouse/raw -WHEEL_VERSION="${PACKAGE_VERSION#v}" -RAW_WHEEL=$(find wheelhouse/raw -maxdepth 1 -name "faiss-${WHEEL_VERSION}-*.whl" -print -quit) +ret=0 +python3.11 -m pip wheel . -w wheelhouse/raw || ret=$? +if [ "$ret" -ne 0 ]; then + echo "FAIL: Python wheel build failed." + exit 1 +fi + +RAW_WHEEL=$(find wheelhouse/raw -maxdepth 1 \ + -name "faiss-1.9.0-*.whl" -print -quit) if [ -z "$RAW_WHEEL" ]; then echo "FAIL: Python wheel was not generated." exit 1 fi +echo "Raw wheel:" +echo "$RAW_WHEEL" + +# ---------------------------------------------------------------------------- # Repair wheel -# Bundle libfaiss.so and other required shared libraries and generate a platform-specific ppc64le wheel. -auditwheel repair "$RAW_WHEEL" -w wheelhouse +# +# Bundle libfaiss.so and other required shared libraries and generate a +# platform-specific ppc64le wheel. +# ---------------------------------------------------------------------------- + +auditwheel repair \ + "$RAW_WHEEL" \ + -w wheelhouse + +# Remove the unrepaired wheel so wheelhouse contains only the publishable +# repaired wheel. rm -f "$RAW_WHEEL" -REPAIRED_WHEEL=$(find wheelhouse -maxdepth 1 -name "faiss-${WHEEL_VERSION}-*.whl" -print -quit) + +REPAIRED_WHEEL=$(find wheelhouse -maxdepth 1 \ + -name "faiss-1.9.0-*.whl" -print -quit) if [ -z "$REPAIRED_WHEEL" ]; then - echo "FAIL: Repaired Python wheel was not generated." + echo "FAIL: Repaired wheel was not generated." + exit 1 +fi + +echo "Repaired wheel:" +echo "$REPAIRED_WHEEL" + +# ---------------------------------------------------------------------------- +# Verify repaired wheel contents +# ---------------------------------------------------------------------------- + +echo "=== Repaired wheel contents ===" + +unzip -l "$REPAIRED_WHEEL" \ + | grep -E 'libfaiss|_swigfaiss|\.libs' + +if ! unzip -l "$REPAIRED_WHEEL" | grep -q 'libfaiss'; then + echo "FAIL: Repaired wheel does not contain libfaiss." exit 1 fi +echo "=== Auditwheel information ===" + +auditwheel show "$REPAIRED_WHEEL" + +# ---------------------------------------------------------------------------- # Install repaired wheel -python3.11 -m pip install --force-reinstall "$REPAIRED_WHEEL" +# ---------------------------------------------------------------------------- + +python3.11 -m pip install \ + --force-reinstall \ + "$REPAIRED_WHEEL" + +# FAISS 1.9.0 was built against NumPy 1.x. +# Prevent pip from leaving NumPy 2.x installed. python3.11 -m pip install \ --force-reinstall \ --no-deps \ @@ -203,16 +325,36 @@ python3.11 -m pip install \ --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ "numpy==1.26.4" +# ---------------------------------------------------------------------------- +# Verify Python imports +# ---------------------------------------------------------------------------- + +python3.11 -c \ + "import numpy; print('NumPy:', numpy.__version__)" + +python3.11 -c \ + "import faiss; print('FAISS:', faiss.__version__)" + +# ---------------------------------------------------------------------------- # Python tests +# ---------------------------------------------------------------------------- + cd "$BUILD_HOME/$PACKAGE_NAME" + ret=0 python3.11 -m pytest ./tests/test_*.py -v || ret=$? - if [ "$ret" -ne 0 ]; then - echo "FAIL: ${PACKAGE_NAME} python tests failed." + echo "FAIL: Python tests failed." exit 2 fi +# ---------------------------------------------------------------------------- # Conclude +# ---------------------------------------------------------------------------- + set +ex + echo "Build and tests complete!" +echo "Publishable wheel:" +echo "$BUILD_HOME/$PACKAGE_NAME/build/faiss/python/$REPAIRED_WHEEL" +echo "Libraries available at [$BUILD_HOME/$PACKAGE_NAME/build/faiss/]" diff --git a/f/faiss/faiss_v1.9.0_ubi_9.8.sh b/f/faiss/faiss_v1.9.0_ubi_9.8.sh index 83f8ac33ed..ab708eb81e 100644 --- a/f/faiss/faiss_v1.9.0_ubi_9.8.sh +++ b/f/faiss/faiss_v1.9.0_ubi_9.8.sh @@ -20,20 +20,22 @@ PACKAGE_ORG="facebookresearch" PACKAGE_VERSION="v1.9.0" PACKAGE_URL="https://github.com/${PACKAGE_ORG}/${PACKAGE_NAME}.git" BUILD_HOME=$(pwd) -PACKAGE_DIR=faiss/python # ---------------------------------------------------------------------------- # Install repositories and dependencies # ---------------------------------------------------------------------------- -# Remove stale CentOS Linux 8 / vault.centos.org repo files if present. +# Remove any stale CentOS Linux 8 / vault.centos.org repo files that may be +# baked into the base image and cause timeout failures at metadata fetch time. find /etc/yum.repos.d/ -maxdepth 1 -name "*.repo" \ ! -name "ubi.repo" \ ! -name "redhat.repo" \ ! -name "almalinux9.repo" \ -delete 2>/dev/null || true +# Add AlmaLinux 9 repos for packages not in UBI (lapack-devel, python3.11-*, swig). # AlmaLinux 9 is ABI-compatible with RHEL 9 and fully supports ppc64le. +# CentOS Stream 9 mirrors dropped ppc64le support (404 on mirror.stream.centos.org). cat > /etc/yum.repos.d/almalinux9.repo << 'EOF' [al9-baseos] name=AlmaLinux 9 - BaseOS @@ -55,25 +57,34 @@ enabled=1 EOF dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -dnf install -y git gcc gcc-c++ cmake file lapack-devel-3.9.0-8.el9.ppc64le swig python3.11-devel python3.11-pip python3.11-pytest python3.11-wheel -pip3.11 install --prefer-binary scipy numpy==1.26.4 auditwheel patchelf --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux - -mkdir -p ~/.local/bin -ln -sf /usr/bin/python3.11 ~/.local/bin/python -ln -sf /usr/bin/python3.11 ~/.local/bin/python3 -export PATH="$HOME/.local/bin:$PATH" +dnf install -y \ + git \ + gcc \ + gcc-c++ \ + cmake \ + file \ + lapack-devel \ + python3.11-devel \ + python3.11-pip \ + pkg-config \ + swig # ---------------------------------------------------------------------------- # Build and install OpenBLAS # ---------------------------------------------------------------------------- cd "$BUILD_HOME" + git clone https://github.com/OpenMathLib/OpenBLAS cd OpenBLAS git checkout v0.3.29 - -make -j"$(nproc)" TARGET=POWER8 DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=0 NUM_THREADS=20 NO_AFFINITY=1 +ret=0 +make -j"$(nproc)" TARGET=POWER8 DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=0 NUM_THREADS=20 NO_AFFINITY=1 || ret=$? +if [ "$ret" -ne 0 ]; then + echo "FAIL: OpenBLAS build failed." + exit 1 +fi make install # ---------------------------------------------------------------------------- @@ -81,7 +92,12 @@ make install # ---------------------------------------------------------------------------- cd "$BUILD_HOME" -git clone --branch v2.3.0 --depth 1 https://github.com/gflags/gflags.git + +git clone \ + --branch v2.3.0 \ + --depth 1 \ + https://github.com/gflags/gflags.git + cd gflags mkdir build cd build @@ -93,16 +109,47 @@ cmake .. \ -DBUILD_STATIC_LIBS=OFF \ -DBUILD_TESTING=OFF -make -j"$(nproc)" +ret=0 +make -j"$(nproc)" || ret=$? +if [ "$ret" -ne 0 ]; then + echo "FAIL: gflags build failed." + exit 1 +fi make install +# ---------------------------------------------------------------------------- +# Install Python dependencies +# ---------------------------------------------------------------------------- + +pip3.11 install \ + --prefer-binary \ + pytest \ + wheel \ + scipy \ + numpy==1.26.4 \ + auditwheel \ + patchelf \ + --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux + +mkdir -p ~/.local/bin + +ln -sf /usr/bin/python3.11 ~/.local/bin/python +ln -sf /usr/bin/python3.11 ~/.local/bin/python3 + +export PATH="$HOME/.local/bin:$PATH" + # ---------------------------------------------------------------------------- # Clone FAISS # ---------------------------------------------------------------------------- cd "$BUILD_HOME" -rm -rf "$PACKAGE_NAME" -git clone "$PACKAGE_URL" -b "$PACKAGE_VERSION" + +if [ -d "$PACKAGE_NAME" ]; then + echo "Directory '$PACKAGE_NAME' already exists, skipping clone." +else + git clone "$PACKAGE_URL" -b "$PACKAGE_VERSION" +fi + cd "$PACKAGE_NAME" # ---------------------------------------------------------------------------- @@ -125,20 +172,25 @@ ret=0 make -j"$(nproc)" || ret=$? if [ "$ret" -ne 0 ]; then - echo "FAIL: ${PACKAGE_NAME} Build failed." + echo "FAIL: Build failed." exit 1 fi +# ---------------------------------------------------------------------------- # Verify native libraries +# ---------------------------------------------------------------------------- + file faiss/libfaiss.so file faiss/python/_swigfaiss.so +# ---------------------------------------------------------------------------- # Run FAISS C++ tests +# ---------------------------------------------------------------------------- + ret=0 make test || ret=$? - if [ "$ret" -ne 0 ]; then - echo "FAIL: ${PACKAGE_NAME} C++ tests failed." + echo "FAIL: C++ tests failed." exit 2 fi @@ -146,33 +198,99 @@ fi # Build Python wheel # ---------------------------------------------------------------------------- -cd "$PACKAGE_DIR" -rm -rf dist wheelhouse -mkdir -p dist wheelhouse +cd faiss/python + +rm -rf wheelhouse +mkdir -p wheelhouse/raw -python3.11 -m pip wheel . -w dist +ret=0 +python3.11 -m pip wheel . -w wheelhouse/raw || ret=$? +if [ "$ret" -ne 0 ]; then + echo "FAIL: Python wheel build failed." + exit 1 +fi -WHEEL_VERSION="${PACKAGE_VERSION#v}" -RAW_WHEEL=$(find dist -maxdepth 1 -name "faiss-${WHEEL_VERSION}-*.whl" -print -quit) +RAW_WHEEL=$(find wheelhouse/raw -maxdepth 1 \ + -name "faiss-1.9.0-*.whl" -print -quit) if [ -z "$RAW_WHEEL" ]; then echo "FAIL: Python wheel was not generated." exit 1 fi +echo "Raw wheel:" +echo "$RAW_WHEEL" + +# ---------------------------------------------------------------------------- # Repair wheel -# Bundle required shared libraries and generate a ppc64le wheel. -auditwheel repair "$RAW_WHEEL" -w wheelhouse +# +# Bundle libfaiss.so and other required shared libraries and generate a +# platform-specific ppc64le wheel. +# ---------------------------------------------------------------------------- -REPAIRED_WHEEL=$(find wheelhouse -maxdepth 1 -name "faiss-${WHEEL_VERSION}-*.whl" -print -quit) +auditwheel repair \ + "$RAW_WHEEL" \ + -w wheelhouse + +# Remove the unrepaired wheel so wheelhouse contains only the publishable +# repaired wheel. +rm -f "$RAW_WHEEL" + +REPAIRED_WHEEL=$(find wheelhouse -maxdepth 1 \ + -name "faiss-1.9.0-*.whl" -print -quit) if [ -z "$REPAIRED_WHEEL" ]; then - echo "FAIL: Repaired Python wheel was not generated." + echo "FAIL: Repaired wheel was not generated." exit 1 fi +echo "Repaired wheel:" +echo "$REPAIRED_WHEEL" + +# ---------------------------------------------------------------------------- +# Verify repaired wheel contents +# ---------------------------------------------------------------------------- + +echo "=== Repaired wheel contents ===" + +unzip -l "$REPAIRED_WHEEL" \ + | grep -E 'libfaiss|_swigfaiss|\.libs' + +if ! unzip -l "$REPAIRED_WHEEL" | grep -q 'libfaiss'; then + echo "FAIL: Repaired wheel does not contain libfaiss." + exit 1 +fi + +echo "=== Auditwheel information ===" + +auditwheel show "$REPAIRED_WHEEL" + +# ---------------------------------------------------------------------------- # Install repaired wheel -python3.11 -m pip install --force-reinstall "$REPAIRED_WHEEL" +# ---------------------------------------------------------------------------- + +python3.11 -m pip install \ + --force-reinstall \ + "$REPAIRED_WHEEL" + +# FAISS 1.9.0 was built against NumPy 1.x. +# Prevent pip from leaving NumPy 2.x installed. +python3.11 -m pip install \ + --force-reinstall \ + --no-deps \ + --only-binary=:all: \ + --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ + "numpy==1.26.4" + +# ---------------------------------------------------------------------------- +# Verify Python imports +# ---------------------------------------------------------------------------- + +python3.11 -c \ + "import numpy; print('NumPy:', numpy.__version__)" + +python3.11 -c \ + "import faiss; print('FAISS:', faiss.__version__)" # ---------------------------------------------------------------------------- # Python tests @@ -182,12 +300,18 @@ cd "$BUILD_HOME/$PACKAGE_NAME" ret=0 python3.11 -m pytest ./tests/test_*.py -v || ret=$? - if [ "$ret" -ne 0 ]; then - echo "FAIL: ${PACKAGE_NAME} Python tests failed." + echo "FAIL: Python tests failed." exit 2 fi +# ---------------------------------------------------------------------------- # Conclude +# ---------------------------------------------------------------------------- + set +ex + echo "Build and tests complete!" +echo "Publishable wheel:" +echo "$BUILD_HOME/$PACKAGE_NAME/build/faiss/python/$REPAIRED_WHEEL" +echo "Libraries available at [$BUILD_HOME/$PACKAGE_NAME/build/faiss/]" From f98224eb74bbc95251b994f56d524466e1274b33 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 7 Sep 2026 13:25:23 +0530 Subject: [PATCH 3/9] Fix CI Issues. --- f/faiss/faiss_v1.9.0_ubi_8.10.sh | 17 ++++++----------- f/faiss/faiss_v1.9.0_ubi_9.8.sh | 26 +++++++++++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/f/faiss/faiss_v1.9.0_ubi_8.10.sh b/f/faiss/faiss_v1.9.0_ubi_8.10.sh index d7440c728d..770a432fec 100644 --- a/f/faiss/faiss_v1.9.0_ubi_8.10.sh +++ b/f/faiss/faiss_v1.9.0_ubi_8.10.sh @@ -20,7 +20,6 @@ PACKAGE_ORG="facebookresearch" PACKAGE_VERSION="v1.9.0" PACKAGE_URL="https://github.com/${PACKAGE_ORG}/${PACKAGE_NAME}.git" BUILD_HOME=$(pwd) -SCRIPT_PATH=$(dirname "$(realpath "$0")") # ---------------------------------------------------------------------------- # Install repositories and dependencies @@ -95,13 +94,15 @@ dnf install -y \ swig # ---------------------------------------------------------------------------- -# Build and install OpenBLAS +# Enable GCC Toolset # ---------------------------------------------------------------------------- +source /opt/rh/gcc-toolset-11/enable +# ---------------------------------------------------------------------------- +# Build and install OpenBLAS +# ---------------------------------------------------------------------------- cd "$BUILD_HOME" - rm -rf OpenBLAS - git clone https://github.com/OpenMathLib/OpenBLAS cd OpenBLAS git checkout v0.3.34 @@ -123,12 +124,6 @@ ldconfig # Verify OpenBLAS is available. ldconfig -p | grep openblas -# ---------------------------------------------------------------------------- -# Enable GCC Toolset -# ---------------------------------------------------------------------------- - -source /opt/rh/gcc-toolset-11/enable - # ---------------------------------------------------------------------------- # Build and install gflags # ---------------------------------------------------------------------------- @@ -357,4 +352,4 @@ set +ex echo "Build and tests complete!" echo "Publishable wheel:" echo "$BUILD_HOME/$PACKAGE_NAME/build/faiss/python/$REPAIRED_WHEEL" -echo "Libraries available at [$BUILD_HOME/$PACKAGE_NAME/build/faiss/]" +echo "Libraries available at [$BUILD_HOME/$PACKAGE_NAME/build/faiss/]" \ No newline at end of file diff --git a/f/faiss/faiss_v1.9.0_ubi_9.8.sh b/f/faiss/faiss_v1.9.0_ubi_9.8.sh index ab708eb81e..7446d21d10 100644 --- a/f/faiss/faiss_v1.9.0_ubi_9.8.sh +++ b/f/faiss/faiss_v1.9.0_ubi_9.8.sh @@ -75,23 +75,34 @@ dnf install -y \ # ---------------------------------------------------------------------------- cd "$BUILD_HOME" +rm -rf OpenBLAS git clone https://github.com/OpenMathLib/OpenBLAS cd OpenBLAS -git checkout v0.3.29 +git checkout v0.3.34 + ret=0 -make -j"$(nproc)" TARGET=POWER8 DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=0 NUM_THREADS=20 NO_AFFINITY=1 || ret=$? +make -j"$(nproc)" libs || ret=$? if [ "$ret" -ne 0 ]; then echo "FAIL: OpenBLAS build failed." exit 1 fi -make install +make -j"$(nproc)" shared +make PREFIX=/usr/local install + +# Make /usr/local/lib visible to the runtime linker. +echo "/usr/local/lib" > /etc/ld.so.conf.d/openblas.conf +ldconfig + +# Verify OpenBLAS is available. +ldconfig -p | grep openblas # ---------------------------------------------------------------------------- # Build and install gflags # ---------------------------------------------------------------------------- cd "$BUILD_HOME" +rm -rf gflags git clone \ --branch v2.3.0 \ @@ -127,6 +138,7 @@ pip3.11 install \ wheel \ scipy \ numpy==1.26.4 \ + swig \ auditwheel \ patchelf \ --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux @@ -143,12 +155,8 @@ export PATH="$HOME/.local/bin:$PATH" # ---------------------------------------------------------------------------- cd "$BUILD_HOME" - -if [ -d "$PACKAGE_NAME" ]; then - echo "Directory '$PACKAGE_NAME' already exists, skipping clone." -else - git clone "$PACKAGE_URL" -b "$PACKAGE_VERSION" -fi +rm -rf "$PACKAGE_NAME" +git clone "$PACKAGE_URL" -b "$PACKAGE_VERSION" cd "$PACKAGE_NAME" From 26ee6e2c15599055dca075e4d816fb3a950b1606 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 7 Sep 2026 13:45:14 +0530 Subject: [PATCH 4/9] FIx Python issues --- f/faiss/faiss_v1.9.0_ubi_8.10.sh | 49 ++++++++++++++------------------ f/faiss/faiss_v1.9.0_ubi_9.8.sh | 42 ++++++++++++++------------- 2 files changed, 45 insertions(+), 46 deletions(-) diff --git a/f/faiss/faiss_v1.9.0_ubi_8.10.sh b/f/faiss/faiss_v1.9.0_ubi_8.10.sh index 770a432fec..484aa71ff5 100644 --- a/f/faiss/faiss_v1.9.0_ubi_8.10.sh +++ b/f/faiss/faiss_v1.9.0_ubi_8.10.sh @@ -82,27 +82,22 @@ if ! rpm -q epel-release &>/dev/null; then rm -f "$EPEL_RPM" fi -dnf install -y \ - git \ - gcc-toolset-11 \ - cmake \ - file \ - lapack-devel \ - python3.11-devel \ - python3.11-pip \ - pkg-config \ - swig +dnf install -y git gcc-toolset-11 cmake file lapack-devel python3-devel python3-pip pkg-config swig # ---------------------------------------------------------------------------- # Enable GCC Toolset # ---------------------------------------------------------------------------- + source /opt/rh/gcc-toolset-11/enable # ---------------------------------------------------------------------------- # Build and install OpenBLAS # ---------------------------------------------------------------------------- + cd "$BUILD_HOME" + rm -rf OpenBLAS + git clone https://github.com/OpenMathLib/OpenBLAS cd OpenBLAS git checkout v0.3.34 @@ -156,11 +151,19 @@ if [ "$ret" -ne 0 ]; then fi make install +# ---------------------------------------------------------------------------- +# Detect Python and create virtual environment +# ---------------------------------------------------------------------------- + +PYTHON_BIN=$(command -v python3 || command -v python) +"${PYTHON_BIN}" -m venv "$BUILD_HOME/faiss-env" +source "$BUILD_HOME/faiss-env/bin/activate" + # ---------------------------------------------------------------------------- # Install Python dependencies # ---------------------------------------------------------------------------- -pip3.11 install \ +pip install \ --prefer-binary \ pytest \ wheel \ @@ -171,13 +174,6 @@ pip3.11 install \ patchelf \ --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux -mkdir -p ~/.local/bin - -ln -sf /usr/bin/python3.11 ~/.local/bin/python -ln -sf /usr/bin/python3.11 ~/.local/bin/python3 - -export PATH="$HOME/.local/bin:$PATH" - # ---------------------------------------------------------------------------- # Clone FAISS # ---------------------------------------------------------------------------- @@ -204,6 +200,7 @@ cmake \ -DBUILD_TESTING=ON \ -DFAISS_ENABLE_C_API=ON \ -DCMAKE_BUILD_TYPE=Release \ + -DPython_EXECUTABLE="$(command -v python)" \ .. ret=0 @@ -242,7 +239,7 @@ rm -rf wheelhouse mkdir -p wheelhouse/raw ret=0 -python3.11 -m pip wheel . -w wheelhouse/raw || ret=$? +python -m pip wheel . -w wheelhouse/raw || ret=$? if [ "$ret" -ne 0 ]; then echo "FAIL: Python wheel build failed." exit 1 @@ -307,13 +304,13 @@ auditwheel show "$REPAIRED_WHEEL" # Install repaired wheel # ---------------------------------------------------------------------------- -python3.11 -m pip install \ +pip install \ --force-reinstall \ "$REPAIRED_WHEEL" # FAISS 1.9.0 was built against NumPy 1.x. # Prevent pip from leaving NumPy 2.x installed. -python3.11 -m pip install \ +pip install \ --force-reinstall \ --no-deps \ --only-binary=:all: \ @@ -324,11 +321,9 @@ python3.11 -m pip install \ # Verify Python imports # ---------------------------------------------------------------------------- -python3.11 -c \ - "import numpy; print('NumPy:', numpy.__version__)" +python -c "import numpy; print('NumPy:', numpy.__version__)" -python3.11 -c \ - "import faiss; print('FAISS:', faiss.__version__)" +python -c "import faiss; print('FAISS:', faiss.__version__)" # ---------------------------------------------------------------------------- # Python tests @@ -337,7 +332,7 @@ python3.11 -c \ cd "$BUILD_HOME/$PACKAGE_NAME" ret=0 -python3.11 -m pytest ./tests/test_*.py -v || ret=$? +python -m pytest ./tests/test_*.py -v || ret=$? if [ "$ret" -ne 0 ]; then echo "FAIL: Python tests failed." exit 2 @@ -352,4 +347,4 @@ set +ex echo "Build and tests complete!" echo "Publishable wheel:" echo "$BUILD_HOME/$PACKAGE_NAME/build/faiss/python/$REPAIRED_WHEEL" -echo "Libraries available at [$BUILD_HOME/$PACKAGE_NAME/build/faiss/]" \ No newline at end of file +echo "Libraries available at [$BUILD_HOME/$PACKAGE_NAME/build/faiss/]" diff --git a/f/faiss/faiss_v1.9.0_ubi_9.8.sh b/f/faiss/faiss_v1.9.0_ubi_9.8.sh index 7446d21d10..26b905e3a0 100644 --- a/f/faiss/faiss_v1.9.0_ubi_9.8.sh +++ b/f/faiss/faiss_v1.9.0_ubi_9.8.sh @@ -33,7 +33,7 @@ find /etc/yum.repos.d/ -maxdepth 1 -name "*.repo" \ ! -name "almalinux9.repo" \ -delete 2>/dev/null || true -# Add AlmaLinux 9 repos for packages not in UBI (lapack-devel, python3.11-*, swig). +# Add AlmaLinux 9 repos for packages not in UBI (lapack-devel, python3-*, swig). # AlmaLinux 9 is ABI-compatible with RHEL 9 and fully supports ppc64le. # CentOS Stream 9 mirrors dropped ppc64le support (404 on mirror.stream.centos.org). cat > /etc/yum.repos.d/almalinux9.repo << 'EOF' @@ -65,8 +65,8 @@ dnf install -y \ cmake \ file \ lapack-devel \ - python3.11-devel \ - python3.11-pip \ + python3-devel \ + python3-pip \ pkg-config \ swig @@ -75,6 +75,7 @@ dnf install -y \ # ---------------------------------------------------------------------------- cd "$BUILD_HOME" + rm -rf OpenBLAS git clone https://github.com/OpenMathLib/OpenBLAS @@ -102,6 +103,7 @@ ldconfig -p | grep openblas # ---------------------------------------------------------------------------- cd "$BUILD_HOME" + rm -rf gflags git clone \ @@ -128,11 +130,19 @@ if [ "$ret" -ne 0 ]; then fi make install +# ---------------------------------------------------------------------------- +# Detect Python and create virtual environment +# ---------------------------------------------------------------------------- + +PYTHON_BIN=$(command -v python3 || command -v python) +"${PYTHON_BIN}" -m venv "$BUILD_HOME/faiss-env" +source "$BUILD_HOME/faiss-env/bin/activate" + # ---------------------------------------------------------------------------- # Install Python dependencies # ---------------------------------------------------------------------------- -pip3.11 install \ +pip install \ --prefer-binary \ pytest \ wheel \ @@ -143,19 +153,14 @@ pip3.11 install \ patchelf \ --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux -mkdir -p ~/.local/bin - -ln -sf /usr/bin/python3.11 ~/.local/bin/python -ln -sf /usr/bin/python3.11 ~/.local/bin/python3 - -export PATH="$HOME/.local/bin:$PATH" - # ---------------------------------------------------------------------------- # Clone FAISS # ---------------------------------------------------------------------------- cd "$BUILD_HOME" + rm -rf "$PACKAGE_NAME" + git clone "$PACKAGE_URL" -b "$PACKAGE_VERSION" cd "$PACKAGE_NAME" @@ -174,6 +179,7 @@ cmake \ -DBUILD_TESTING=ON \ -DFAISS_ENABLE_C_API=ON \ -DCMAKE_BUILD_TYPE=Release \ + -DPython_EXECUTABLE="$(command -v python)" \ .. ret=0 @@ -212,7 +218,7 @@ rm -rf wheelhouse mkdir -p wheelhouse/raw ret=0 -python3.11 -m pip wheel . -w wheelhouse/raw || ret=$? +python -m pip wheel . -w wheelhouse/raw || ret=$? if [ "$ret" -ne 0 ]; then echo "FAIL: Python wheel build failed." exit 1 @@ -277,13 +283,13 @@ auditwheel show "$REPAIRED_WHEEL" # Install repaired wheel # ---------------------------------------------------------------------------- -python3.11 -m pip install \ +pip install \ --force-reinstall \ "$REPAIRED_WHEEL" # FAISS 1.9.0 was built against NumPy 1.x. # Prevent pip from leaving NumPy 2.x installed. -python3.11 -m pip install \ +pip install \ --force-reinstall \ --no-deps \ --only-binary=:all: \ @@ -294,11 +300,9 @@ python3.11 -m pip install \ # Verify Python imports # ---------------------------------------------------------------------------- -python3.11 -c \ - "import numpy; print('NumPy:', numpy.__version__)" +python -c "import numpy; print('NumPy:', numpy.__version__)" -python3.11 -c \ - "import faiss; print('FAISS:', faiss.__version__)" +python -c "import faiss; print('FAISS:', faiss.__version__)" # ---------------------------------------------------------------------------- # Python tests @@ -307,7 +311,7 @@ python3.11 -c \ cd "$BUILD_HOME/$PACKAGE_NAME" ret=0 -python3.11 -m pytest ./tests/test_*.py -v || ret=$? +python -m pytest ./tests/test_*.py -v || ret=$? if [ "$ret" -ne 0 ]; then echo "FAIL: Python tests failed." exit 2 From 9217b4b21d669fc7ddaccb931b5b95a19fa57559 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 7 Sep 2026 14:16:49 +0530 Subject: [PATCH 5/9] fix toolset issues. --- f/faiss/faiss_v1.9.0_ubi_8.10.sh | 4 ++-- f/faiss/faiss_v1.9.0_ubi_9.8.sh | 18 +++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/f/faiss/faiss_v1.9.0_ubi_8.10.sh b/f/faiss/faiss_v1.9.0_ubi_8.10.sh index 484aa71ff5..b482375484 100644 --- a/f/faiss/faiss_v1.9.0_ubi_8.10.sh +++ b/f/faiss/faiss_v1.9.0_ubi_8.10.sh @@ -82,13 +82,13 @@ if ! rpm -q epel-release &>/dev/null; then rm -f "$EPEL_RPM" fi -dnf install -y git gcc-toolset-11 cmake file lapack-devel python3-devel python3-pip pkg-config swig +dnf install -y git gcc-toolset-12 cmake file lapack-devel python3-devel python3-pip pkg-config swig # ---------------------------------------------------------------------------- # Enable GCC Toolset # ---------------------------------------------------------------------------- -source /opt/rh/gcc-toolset-11/enable +source /opt/rh/gcc-toolset-12/enable # ---------------------------------------------------------------------------- # Build and install OpenBLAS diff --git a/f/faiss/faiss_v1.9.0_ubi_9.8.sh b/f/faiss/faiss_v1.9.0_ubi_9.8.sh index 26b905e3a0..a224a6b125 100644 --- a/f/faiss/faiss_v1.9.0_ubi_9.8.sh +++ b/f/faiss/faiss_v1.9.0_ubi_9.8.sh @@ -58,17 +58,13 @@ EOF dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -dnf install -y \ - git \ - gcc \ - gcc-c++ \ - cmake \ - file \ - lapack-devel \ - python3-devel \ - python3-pip \ - pkg-config \ - swig +dnf install -y git gcc-toolset-13 cmake file lapack-devel python3-devel python3-pip pkg-config swig + +# ---------------------------------------------------------------------------- +# Enable GCC Toolset +# ---------------------------------------------------------------------------- + +source /opt/rh/gcc-toolset-13/enable # ---------------------------------------------------------------------------- # Build and install OpenBLAS From 5d9a5cf4c6ce04472174df848f5f4f9e9f30e490 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 7 Sep 2026 14:38:55 +0530 Subject: [PATCH 6/9] fix pip issues --- f/faiss/faiss_v1.9.0_ubi_8.10.sh | 1 + f/faiss/faiss_v1.9.0_ubi_9.8.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/f/faiss/faiss_v1.9.0_ubi_8.10.sh b/f/faiss/faiss_v1.9.0_ubi_8.10.sh index b482375484..c8630c13e9 100644 --- a/f/faiss/faiss_v1.9.0_ubi_8.10.sh +++ b/f/faiss/faiss_v1.9.0_ubi_8.10.sh @@ -158,6 +158,7 @@ make install PYTHON_BIN=$(command -v python3 || command -v python) "${PYTHON_BIN}" -m venv "$BUILD_HOME/faiss-env" source "$BUILD_HOME/faiss-env/bin/activate" +pip install --upgrade pip # ---------------------------------------------------------------------------- # Install Python dependencies diff --git a/f/faiss/faiss_v1.9.0_ubi_9.8.sh b/f/faiss/faiss_v1.9.0_ubi_9.8.sh index a224a6b125..fe7a833122 100644 --- a/f/faiss/faiss_v1.9.0_ubi_9.8.sh +++ b/f/faiss/faiss_v1.9.0_ubi_9.8.sh @@ -133,6 +133,7 @@ make install PYTHON_BIN=$(command -v python3 || command -v python) "${PYTHON_BIN}" -m venv "$BUILD_HOME/faiss-env" source "$BUILD_HOME/faiss-env/bin/activate" +pip install --upgrade pip # ---------------------------------------------------------------------------- # Install Python dependencies From 2fee662d4aea33a521662f6a3411948cc7dc641c Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 7 Sep 2026 15:40:11 +0530 Subject: [PATCH 7/9] fix wheel creation issues. --- f/faiss/faiss_v1.9.0_ubi_8.10.sh | 7 ++++--- f/faiss/faiss_v1.9.0_ubi_9.8.sh | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/f/faiss/faiss_v1.9.0_ubi_8.10.sh b/f/faiss/faiss_v1.9.0_ubi_8.10.sh index c8630c13e9..6132322f57 100644 --- a/f/faiss/faiss_v1.9.0_ubi_8.10.sh +++ b/f/faiss/faiss_v1.9.0_ubi_8.10.sh @@ -82,7 +82,7 @@ if ! rpm -q epel-release &>/dev/null; then rm -f "$EPEL_RPM" fi -dnf install -y git gcc-toolset-12 cmake file lapack-devel python3-devel python3-pip pkg-config swig +dnf install -y git gcc-toolset-12 cmake file lapack-devel python3-devel python3-pip pkg-config swig unzip # ---------------------------------------------------------------------------- # Enable GCC Toolset @@ -166,14 +166,15 @@ pip install --upgrade pip pip install \ --prefer-binary \ + --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ + --index-strategy=unsafe-best-match \ pytest \ wheel \ scipy \ numpy==1.26.4 \ swig \ auditwheel \ - patchelf \ - --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux + patchelf # ---------------------------------------------------------------------------- # Clone FAISS diff --git a/f/faiss/faiss_v1.9.0_ubi_9.8.sh b/f/faiss/faiss_v1.9.0_ubi_9.8.sh index fe7a833122..31c008fc7e 100644 --- a/f/faiss/faiss_v1.9.0_ubi_9.8.sh +++ b/f/faiss/faiss_v1.9.0_ubi_9.8.sh @@ -58,7 +58,7 @@ EOF dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -dnf install -y git gcc-toolset-13 cmake file lapack-devel python3-devel python3-pip pkg-config swig +dnf install -y git gcc-toolset-13 cmake file lapack-devel python3-devel python3-pip pkg-config swig unzip # ---------------------------------------------------------------------------- # Enable GCC Toolset @@ -141,14 +141,15 @@ pip install --upgrade pip pip install \ --prefer-binary \ + --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ + --index-strategy=unsafe-best-match \ pytest \ wheel \ scipy \ numpy==1.26.4 \ swig \ auditwheel \ - patchelf \ - --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux + patchelf # ---------------------------------------------------------------------------- # Clone FAISS From 1ff7ea02cf7623069ece307b99338ef42ef7eee8 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 7 Sep 2026 16:40:20 +0530 Subject: [PATCH 8/9] fix dep issues --- f/faiss/faiss_v1.9.0_ubi_8.10.sh | 18 ++++++------------ f/faiss/faiss_v1.9.0_ubi_9.8.sh | 18 ++++++------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/f/faiss/faiss_v1.9.0_ubi_8.10.sh b/f/faiss/faiss_v1.9.0_ubi_8.10.sh index 6132322f57..28521722c0 100644 --- a/f/faiss/faiss_v1.9.0_ubi_8.10.sh +++ b/f/faiss/faiss_v1.9.0_ubi_8.10.sh @@ -160,18 +160,21 @@ PYTHON_BIN=$(command -v python3 || command -v python) source "$BUILD_HOME/faiss-env/bin/activate" pip install --upgrade pip +# Install numpy from IBM ppc64le wheel index first. +pip install \ + --prefer-binary \ + --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ + "numpy==1.26.4" + # ---------------------------------------------------------------------------- # Install Python dependencies # ---------------------------------------------------------------------------- pip install \ --prefer-binary \ - --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ - --index-strategy=unsafe-best-match \ pytest \ wheel \ scipy \ - numpy==1.26.4 \ swig \ auditwheel \ patchelf @@ -310,15 +313,6 @@ pip install \ --force-reinstall \ "$REPAIRED_WHEEL" -# FAISS 1.9.0 was built against NumPy 1.x. -# Prevent pip from leaving NumPy 2.x installed. -pip install \ - --force-reinstall \ - --no-deps \ - --only-binary=:all: \ - --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ - "numpy==1.26.4" - # ---------------------------------------------------------------------------- # Verify Python imports # ---------------------------------------------------------------------------- diff --git a/f/faiss/faiss_v1.9.0_ubi_9.8.sh b/f/faiss/faiss_v1.9.0_ubi_9.8.sh index 31c008fc7e..b6c0e341c9 100644 --- a/f/faiss/faiss_v1.9.0_ubi_9.8.sh +++ b/f/faiss/faiss_v1.9.0_ubi_9.8.sh @@ -135,18 +135,21 @@ PYTHON_BIN=$(command -v python3 || command -v python) source "$BUILD_HOME/faiss-env/bin/activate" pip install --upgrade pip +# Install numpy from IBM ppc64le wheel index first. +pip install \ + --prefer-binary \ + --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ + "numpy==1.26.4" + # ---------------------------------------------------------------------------- # Install Python dependencies # ---------------------------------------------------------------------------- pip install \ --prefer-binary \ - --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ - --index-strategy=unsafe-best-match \ pytest \ wheel \ scipy \ - numpy==1.26.4 \ swig \ auditwheel \ patchelf @@ -285,15 +288,6 @@ pip install \ --force-reinstall \ "$REPAIRED_WHEEL" -# FAISS 1.9.0 was built against NumPy 1.x. -# Prevent pip from leaving NumPy 2.x installed. -pip install \ - --force-reinstall \ - --no-deps \ - --only-binary=:all: \ - --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ - "numpy==1.26.4" - # ---------------------------------------------------------------------------- # Verify Python imports # ---------------------------------------------------------------------------- From 43f1ff6659fd1493aedcbf49ad5087e1123d2fef Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 7 Sep 2026 17:35:52 +0530 Subject: [PATCH 9/9] fix numpy issues --- f/faiss/faiss_v1.9.0_ubi_8.10.sh | 15 +++++++++------ f/faiss/faiss_v1.9.0_ubi_9.8.sh | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/f/faiss/faiss_v1.9.0_ubi_8.10.sh b/f/faiss/faiss_v1.9.0_ubi_8.10.sh index 28521722c0..b4ac32292e 100644 --- a/f/faiss/faiss_v1.9.0_ubi_8.10.sh +++ b/f/faiss/faiss_v1.9.0_ubi_8.10.sh @@ -158,13 +158,16 @@ make install PYTHON_BIN=$(command -v python3 || command -v python) "${PYTHON_BIN}" -m venv "$BUILD_HOME/faiss-env" source "$BUILD_HOME/faiss-env/bin/activate" -pip install --upgrade pip -# Install numpy from IBM ppc64le wheel index first. -pip install \ - --prefer-binary \ - --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ - "numpy==1.26.4" +# Download numpy ppc64le wheel directly from IBM index and install from disk. +# UBI 8 has glibc 2.28 — use manylinux_2_27 wheels. +PYVER=$("${PYTHON_BIN}" -c "import sys; print(f'cp{sys.version_info.major}{sys.version_info.minor}')") +NUMPY_WHL="numpy-2.4.6+ppc64le1-${PYVER}-${PYVER}-manylinux_2_27_ppc64le.whl" +curl -fsSL \ + "https://wheels.developerfirst.ibm.com/ppc64le/linux/${NUMPY_WHL}" \ + -o "/tmp/${NUMPY_WHL}" +pip install "/tmp/${NUMPY_WHL}" +rm -f "/tmp/${NUMPY_WHL}" # ---------------------------------------------------------------------------- # Install Python dependencies diff --git a/f/faiss/faiss_v1.9.0_ubi_9.8.sh b/f/faiss/faiss_v1.9.0_ubi_9.8.sh index b6c0e341c9..b8590c0f32 100644 --- a/f/faiss/faiss_v1.9.0_ubi_9.8.sh +++ b/f/faiss/faiss_v1.9.0_ubi_9.8.sh @@ -133,13 +133,16 @@ make install PYTHON_BIN=$(command -v python3 || command -v python) "${PYTHON_BIN}" -m venv "$BUILD_HOME/faiss-env" source "$BUILD_HOME/faiss-env/bin/activate" -pip install --upgrade pip -# Install numpy from IBM ppc64le wheel index first. -pip install \ - --prefer-binary \ - --extra-index-url=https://wheels.developerfirst.ibm.com/ppc64le/linux \ - "numpy==1.26.4" +# Download numpy ppc64le wheel directly from IBM index and install from disk. +# UBI 9 has glibc 2.34 — use manylinux_2_34 IBM-optimized wheels. +PYVER=$("${PYTHON_BIN}" -c "import sys; print(f'cp{sys.version_info.major}{sys.version_info.minor}')") +NUMPY_WHL="numpy-2.4.6+ppc64le1-${PYVER}-${PYVER}-manylinux_2_34_ppc64le.whl" +curl -fsSL \ + "https://wheels.developerfirst.ibm.com/ppc64le/linux/${NUMPY_WHL}" \ + -o "/tmp/${NUMPY_WHL}" +pip install "/tmp/${NUMPY_WHL}" +rm -f "/tmp/${NUMPY_WHL}" # ---------------------------------------------------------------------------- # Install Python dependencies