mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-12 02:13:36 +00:00
Add faiss-gpu pip wheel packaging (#5131)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5131 Add pip wheel packaging for `faiss-gpu`, enabling `pip install faiss-gpu` from PyPI. Builds GPU wheels for Linux x86_64, Python 3.10-3.13, with CUDA 12.6 on manylinux_2_28. **New files:** - `pyproject-gpu.toml`: scikit-build-core config for faiss-gpu. Enables CUDA GPU support, uses Dynamic Dispatch, OpenBLAS, and excludes CUDA runtime libs (provided by nvidia-cuda-runtime-cu12 pip dependency). - `.github/workflows/build-pip-gpu.yml`: CI workflow for GPU wheels using cibuildwheel on GPU runners (4-core-ubuntu-gpu-t4). - `tests/test_wheel_smoke_gpu.py`: GPU smoke tests validating GPU detection, StandardGpuResources, GPU FlatL2/IP search, IVF+PQ on GPU, CPU<->GPU transfer roundtrip, and GPU serialization. **Modified files:** - `python/__init__.py`: Added `_preload_gpu_libs()` to pre-load CUDA shared libraries from pip packages before SWIG import. No-op on CPU-only installs. - `.github/workflows/build.yml`: Added `build-pip-gpu` workflow call. - `tests/BUCK`: Added `test_wheel_smoke_gpu` target for Buck CI. Reviewed By: junjieqi Differential Revision: D97507525 fbshipit-source-id: f8b5fa08405aa53267e791c2c0d263e2d6190741
This commit is contained in:
committed by
meta-codesync[bot]
parent
09937153dc
commit
5d9aae6ee8
@@ -0,0 +1,97 @@
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
name: Build GPU pip wheel
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
# One run per ref. Tag pushes are not cancelable — a half-canceled release
|
||||
# build leaves PyPI in an inconsistent state. Branch/PR runs supersede.
|
||||
group: gpu-pip-${{ github.ref }}
|
||||
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||
|
||||
jobs:
|
||||
build-faiss-gpu:
|
||||
name: Build & test faiss-gpu
|
||||
runs-on: 4-core-ubuntu-gpu-t4
|
||||
timeout-minutes: 90
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Activate GPU pyproject.toml
|
||||
# cibuildwheel + scikit-build-core both require literal pyproject.toml.
|
||||
# Workspace is fresh per job (actions/checkout creates new tree).
|
||||
run: cp pyproject-gpu.toml pyproject.toml
|
||||
|
||||
- name: Set up Python
|
||||
# Pin host Python explicitly: the 4-core-ubuntu-gpu-t4 runner image
|
||||
# ships a broken Python 3.14.4 in its tool cache (libpython3.14.so.1.0
|
||||
# missing), and pypa/cibuildwheel picks that up by default.
|
||||
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Build wheel (cibuildwheel)
|
||||
uses: pypa/cibuildwheel@ee02a1537ce3071a004a6b08c41e72f0fdc42d9a # v3.4.0
|
||||
env:
|
||||
CIBW_BUILD_VERBOSITY: 1
|
||||
|
||||
- name: Upload wheel
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: wheels-gpu
|
||||
path: wheelhouse/*.whl
|
||||
|
||||
publish-gpu:
|
||||
name: Publish faiss-gpu to PyPI
|
||||
needs: [build-faiss-gpu]
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
||||
environment:
|
||||
name: pypi
|
||||
url: https://pypi.org/p/faiss-gpu
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Download wheel
|
||||
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
|
||||
with:
|
||||
name: wheels-gpu
|
||||
path: dist
|
||||
- name: Publish to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1
|
||||
with:
|
||||
verbose: true
|
||||
attestations: false
|
||||
|
||||
publish-testpypi-gpu:
|
||||
name: Publish faiss-gpu to TestPyPI
|
||||
needs: [build-faiss-gpu]
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
environment:
|
||||
name: testpypi
|
||||
url: https://test.pypi.org/p/faiss-gpu
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Download wheel
|
||||
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
|
||||
with:
|
||||
name: wheels-gpu
|
||||
path: dist
|
||||
- name: Publish to TestPyPI
|
||||
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1
|
||||
with:
|
||||
repository-url: https://test.pypi.org/legacy/
|
||||
skip-existing: true
|
||||
verbose: true
|
||||
@@ -17,3 +17,5 @@ jobs:
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
||||
build-pip:
|
||||
uses: ./.github/workflows/build-pip.yml
|
||||
build-pip-gpu:
|
||||
uses: ./.github/workflows/build-pip-gpu.yml
|
||||
|
||||
Reference in New Issue
Block a user