Initial commit

This commit is contained in:
yichuan520030910320
2025-06-30 09:05:05 +00:00
commit 46f6cc100b
1231 changed files with 278432 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
python:
- 3.9
- 3.10
- 3.11
- 3.12 # [not aarch64]

View File

@@ -0,0 +1,136 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
{% set version = environ.get('GIT_DESCRIBE_TAG').lstrip('v') %}
{% set suffix = "_nightly" if environ.get('PACKAGE_TYPE') == 'nightly' else "" %}
{% set number = GIT_DESCRIBE_NUMBER %}
{% if cudatoolkit == '11.8.0' %}
{% set cuda_constraints=">=11.4,<12" %}
{% set libcublas_constraints=">=11.6,<12" %}
{% set cudart_constraints="=12.6.77" %}
{% elif cudatoolkit == '12.4.0' %}
{% set cuda_constraints=">=12.1,<12.5" %}
{% set libcublas_constraints=">=12.1,<13" %}
{% set cudart_constraints=">=12.4,<12.5" %}
{% endif %}
package:
name: faiss-pkg
version: {{ version }}
build:
number: {{ number }}
about:
home: https://github.com/facebookresearch/faiss
license: MIT
license_family: MIT
license_file: LICENSE
summary: A library for efficient similarity search and clustering of dense vectors.
source:
git_url: ../../
outputs:
- name: libfaiss
script: build-lib.sh # [x86_64 and not win and not osx]
script: build-lib-osx.sh # [x86_64 and osx]
script: build-lib-arm64.sh # [not x86_64]
script: build-lib.bat # [win]
build:
string: "h{{ PKG_HASH }}_{{ number }}_cuda{{ cudatoolkit }}_cuvs{{ suffix }}"
run_exports:
- {{ pin_compatible('libfaiss', exact=True) }}
script_env:
- CUDA_ARCHS
requirements:
build:
- {{ compiler('cxx') }} =12.4
- sysroot_linux-64 =2.17 # [linux64]
- llvm-openmp # [osx]
- cmake >=3.26.4
- make =4.2 # [not win]
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- mkl =2023 # [x86_64]
- mkl-devel =2023 # [x86_64]
- cuda-toolkit {{ cudatoolkit }}
- cuda-cudart {{ cudart_constraints }}
- cuda-cudart-dev {{ cudart_constraints }}
- cuda-cudart-static {{ cudart_constraints }}
- cuda-cudart_linux-64 {{ cudart_constraints }} # [linux64]
- cuda-cudart-dev_linux-64 {{ cudart_constraints }} # [linux64]
- cuda-cudart-static_linux-64 {{ cudart_constraints }} # [linux64]
host:
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- mkl =2023 # [x86_64]
- openblas =0.3.29 # [not x86_64]
- libcuvs =24.12
- cuda-version {{ cuda_constraints }}
run:
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- mkl =2023 # [x86_64]
- openblas =0.3.29 # [not x86_64]
- cuda-cudart {{ cuda_constraints }}
- libcublas {{ libcublas_constraints }}
- libcuvs =24.12
- cuda-version {{ cuda_constraints }}
- libnvjitlink
test:
requires:
- conda-build
commands:
- test -f $PREFIX/lib/libfaiss$SHLIB_EXT # [not win]
- test -f $PREFIX/lib/libfaiss_avx2$SHLIB_EXT # [x86_64 and not win]
- conda inspect linkages -p $PREFIX $PKG_NAME # [not win]
- conda inspect objects -p $PREFIX $PKG_NAME # [osx]
- name: faiss-gpu-cuvs
script: build-pkg.sh # [x86_64 and not win and not osx]
script: build-pkg-osx.sh # [x86_64 and osx]
script: build-pkg-arm64.sh # [not x86_64]
script: build-pkg.bat # [win]
build:
string: "py{{ PY_VER }}_h{{ PKG_HASH }}_{{ number }}_cuda{{ cudatoolkit }}{{ suffix }}"
requirements:
build:
- {{ compiler('cxx') }} =12.4
- sysroot_linux-64 =2.17 # [linux64]
- swig =4.0
- cmake >=3.26.4
- make =4.2 # [not win]
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- mkl =2023.0 # [x86_64]
- cuda-toolkit {{ cudatoolkit }}
host:
- mkl =2023.0 # [x86_64]
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- python {{ python }}
- numpy >=1.19,<2
- {{ pin_subpackage('libfaiss', exact=True) }}
run:
- mkl =2023.0 # [x86_64]
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- python {{ python }}
- numpy >=1.19,<2
- packaging
- {{ pin_subpackage('libfaiss', exact=True) }}
test:
requires:
- numpy >=1.19,<2
- scipy
- pytorch <2.5
- pytorch-cuda {{ cuda_constraints }}
commands:
- python -X faulthandler -m unittest discover -v -s tests/ -p "test_*"
- python -X faulthandler -m unittest discover -v -s tests/ -p "torch_*"
- cp tests/common_faiss_tests.py faiss/gpu/test
- python -X faulthandler -m unittest discover -v -s faiss/gpu/test/ -p "test_*"
- python -X faulthandler -m unittest discover -v -s faiss/gpu/test/ -p "torch_*"
- sh test_cpu_dispatch.sh # [linux64]
files:
- test_cpu_dispatch.sh # [linux64]
source_files:
- tests/
- faiss/gpu/test/

View File

@@ -0,0 +1,122 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
{% set version = environ.get('GIT_DESCRIBE_TAG').lstrip('v') %}
{% set suffix = "_nightly" if environ.get('PACKAGE_TYPE') == 'nightly' else "" %}
{% set number = GIT_DESCRIBE_NUMBER %}
{% if cudatoolkit == '11.4.4' %}
{% set cuda_constraints=">=11.4,<12" %}
{% set libcublas_constraints=">=11.6,<12" %}
{% elif cudatoolkit == '12.1.1' %}
{% set cuda_constraints=">=12.1,<13" %}
{% set libcublas_constraints=">=12.1,<13" %}
{% endif %}
package:
name: faiss-pkg
version: {{ version }}
build:
number: {{ number }}
about:
home: https://github.com/facebookresearch/faiss
license: MIT
license_family: MIT
license_file: LICENSE
summary: A library for efficient similarity search and clustering of dense vectors.
source:
git_url: ../../
outputs:
- name: libfaiss
script: build-lib.sh # [x86_64 and not win and not osx]
script: build-lib-osx.sh # [x86_64 and osx]
script: build-lib-arm64.sh # [not x86_64]
script: build-lib.bat # [win]
build:
string: "h{{ PKG_HASH }}_{{ number }}_cuda{{ cudatoolkit }}{{ suffix }}"
run_exports:
- {{ pin_compatible('libfaiss', exact=True) }}
script_env:
- CUDA_ARCHS
- FAISS_FLATTEN_CONDA_INCLUDES
requirements:
build:
- {{ compiler('cxx') }}
- sysroot_linux-64 =2.17 # [linux64]
- llvm-openmp # [osx]
- cmake >=3.24.0
- make =4.2 # [not win and not (osx and arm64)]
- make =4.4 # [osx and arm64]
- mkl-devel =2023.0 # [x86_64]
- cuda-toolkit {{ cudatoolkit }}
- gcc_linux-64 =11.2 # [cudatoolkit == '11.4.4']
host:
- mkl =2023.0 # [x86_64]
- openblas =0.3.29 # [not x86_64]
run:
- mkl =2023.0 # [x86_64]
- openblas =0.3.29 # [not x86_64]
- cuda-cudart {{ cuda_constraints }}
- libcublas {{ libcublas_constraints }}
test:
requires:
- conda-build
commands:
- test -f $PREFIX/lib/libfaiss$SHLIB_EXT # [not win]
- test -f $PREFIX/lib/libfaiss_avx2$SHLIB_EXT # [x86_64 and not win]
- conda inspect linkages -p $PREFIX $PKG_NAME # [not win]
- conda inspect objects -p $PREFIX $PKG_NAME # [osx]
- name: faiss-gpu
script: build-pkg.sh # [x86_64 and not win and not osx]
script: build-pkg-osx.sh # [x86_64 and osx]
script: build-pkg-arm64.sh # [not x86_64]
script: build-pkg.bat # [win]
build:
string: "py{{ PY_VER }}_h{{ PKG_HASH }}_{{ number }}_cuda{{ cudatoolkit }}{{ suffix }}"
requirements:
build:
- {{ compiler('cxx') }}
- sysroot_linux-64 =2.17 # [linux64]
- swig =4.0
- cmake >=3.24.0
- make =4.2 # [not win and not (osx and arm64)]
- make =4.4 # [osx and arm64]
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
- cuda-toolkit {{ cudatoolkit }}
- mkl-devel =2023.0 # [x86_64]
host:
- mkl =2023.0 # [x86_64]
- python {{ python }}
- numpy >=1.19,<2
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
- {{ pin_subpackage('libfaiss', exact=True) }}
run:
- mkl =2023.0 # [x86_64]
- python {{ python }}
- numpy >=1.19,<2
- packaging
- {{ pin_subpackage('libfaiss', exact=True) }}
test:
requires:
- numpy >=1.19,<2
- scipy
- pytorch <2.5
- pytorch-cuda {{ cuda_constraints }}
commands:
- python -X faulthandler -m unittest discover -v -s tests/ -p "test_*"
- python -X faulthandler -m unittest discover -v -s tests/ -p "torch_*"
- cp tests/common_faiss_tests.py faiss/gpu/test
- python -X faulthandler -m unittest discover -v -s faiss/gpu/test/ -p "test_*"
- python -X faulthandler -m unittest discover -v -s faiss/gpu/test/ -p "torch_*"
- sh test_cpu_dispatch.sh # [linux64]
files:
- test_cpu_dispatch.sh # [linux64]
source_files:
- tests/
- faiss/gpu/test/

View File

@@ -0,0 +1,28 @@
@REM Copyright (c) Meta Platforms, Inc. and affiliates.
@REM
@REM This source code is licensed under the MIT license found in the
@REM LICENSE file in the root directory of this source tree.
:: Copyright (c) Facebook, Inc. and its affiliates.
::
:: This source code is licensed under the MIT license found in the
:: LICENSE file in the root directory of this source tree.
:: Build libfaiss.so.
cmake -B _build ^
-T v141 ^
-A x64 ^
-G "Visual Studio 16 2019" ^
-DBUILD_SHARED_LIBS=ON ^
-DBUILD_TESTING=OFF ^
-DFAISS_ENABLE_GPU=OFF ^
-DFAISS_ENABLE_PYTHON=OFF ^
-DBLA_VENDOR=Intel10_64_dyn ^
.
if %errorlevel% neq 0 exit /b %errorlevel%
cmake --build _build --config Release -j %CPU_COUNT%
if %errorlevel% neq 0 exit /b %errorlevel%
cmake --install _build --config Release --prefix %PREFIX%
if %errorlevel% neq 0 exit /b %errorlevel%

View File

@@ -0,0 +1,28 @@
@REM Copyright (c) Meta Platforms, Inc. and affiliates.
@REM
@REM This source code is licensed under the MIT license found in the
@REM LICENSE file in the root directory of this source tree.
:: Copyright (c) Facebook, Inc. and its affiliates.
::
:: This source code is licensed under the MIT license found in the
:: LICENSE file in the root directory of this source tree.
:: Build vanilla version (no avx).
cmake -B _build_python_%PY_VER% ^
-T v141 ^
-A x64 ^
-G "Visual Studio 16 2019" ^
-DFAISS_ENABLE_GPU=OFF ^
-DPython_EXECUTABLE=%PYTHON% ^
faiss/python
if %errorlevel% neq 0 exit /b %errorlevel%
cmake --build _build_python_%PY_VER% --config Release -j %CPU_COUNT%
if %errorlevel% neq 0 exit /b %errorlevel%
:: Build actual python module.
cd _build_python_%PY_VER%/
%PYTHON% setup.py install --single-version-externally-managed --record=record.txt --prefix=%PREFIX%
if %errorlevel% neq 0 exit /b %errorlevel%

View File

@@ -0,0 +1,156 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
{% set version = environ.get('GIT_DESCRIBE_TAG').lstrip('v') %}
{% set suffix = "_nightly" if environ.get('PACKAGE_TYPE') == 'nightly' else "" %}
{% set number = GIT_DESCRIBE_NUMBER %}
package:
name: faiss-pkg
version: {{ version }}
build:
number: {{ number }}
about:
home: https://github.com/facebookresearch/faiss
license: MIT
license_family: MIT
license_file: LICENSE
summary: A library for efficient similarity search and clustering of dense vectors.
source:
git_url: ../../
outputs:
- name: libfaiss
script: build-lib.sh # [x86_64 and not win and not osx]
script: build-lib-osx.sh # [x86_64 and osx]
script: build-lib-arm64.sh # [not x86_64]
script: build-lib.bat # [win]
build:
string: "py{{ PY_VER }}_h{{ PKG_HASH }}_{{ number }}_cpu{{ suffix }}"
run_exports:
- {{ pin_compatible('libfaiss', exact=True) }}
requirements:
build:
- python {{ python }}
- {{ compiler('cxx') }}
- sysroot_linux-64 =2.17 # [linux64]
- llvm-openmp # [osx or linux64]
- cmake >=3.24.0
- make =4.2 # [not win and not (osx and arm64)]
- make =4.4 # [osx and arm64]
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
- mkl-devel =2023.0 # [x86_64]
- python_abi <3.12
{% elif PY_VER == '3.12' %}
- mkl-devel >=2023.2.0 # [x86_64 and not win]
- mkl-devel =2023.1.0 # [x86_64 and win]
- python_abi =3.12
{% endif %}
host:
- python {{ python }}
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
- mkl =2023.0 # [x86_64]
- python_abi <3.12
{% elif PY_VER == '3.12' %}
- mkl >=2023.2.0 # [x86_64 and not win]
- mkl =2023.1.0 # [x86_64 and win]
- python_abi =3.12
{% endif %}
- openblas =0.3.29 # [not x86_64]
run:
- python {{ python }}
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
- mkl =2023.0 # [x86_64]
- python_abi <3.12
{% elif PY_VER == '3.12' %}
- mkl >=2023.2.0 # [x86_64 and not win]
- mkl =2023.1.0 # [x86_64 and win]
- python_abi =3.12
{% endif %}
- openblas =0.3.29 # [not x86_64]
test:
requires:
- conda-build =25.1.2
commands:
- test -f $PREFIX/lib/libfaiss$SHLIB_EXT # [not win]
- test -f $PREFIX/lib/libfaiss_avx2$SHLIB_EXT # [x86_64 and not win]
- conda inspect linkages -p $PREFIX $PKG_NAME # [not win]
- conda inspect objects -p $PREFIX $PKG_NAME # [osx]
- name: faiss-cpu
script: build-pkg.sh # [x86_64 and not win and not osx]
script: build-pkg-osx.sh # [x86_64 and osx]
script: build-pkg-arm64.sh # [not x86_64]
script: build-pkg.bat # [win]
build:
string: "py{{ PY_VER }}_h{{ PKG_HASH }}_{{ number }}_cpu{{ suffix }}"
requirements:
build:
- python {{ python }}
- {{ compiler('cxx') }}
- sysroot_linux-64 =2.17 # [linux64]
- swig =4.0
- cmake >=3.24.0
- make =4.2 # [not win and not (osx and arm64)]
- make =4.4 # [osx and arm64]
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
- mkl =2023.0 # [x86_64]
- python_abi <3.12
{% elif PY_VER == '3.12' %}
- mkl >=2023.2.0 # [x86_64 and not win]
- mkl =2023.1.0 # [x86_64 and win]
- python_abi =3.12
{% endif %}
host:
- python {{ python }}
- numpy >=1.19,<2
- {{ pin_subpackage('libfaiss', exact=True) }}
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64 and not win]
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
- mkl =2023.0 # [x86_64]
- python_abi <3.12
{% elif PY_VER == '3.12' %}
- mkl >=2023.2.0 # [x86_64 and not win]
- mkl =2023.1.0 # [x86_64 and win]
- python_abi =3.12
{% endif %}
run:
- python {{ python }}
- numpy >=1.19,<2
- packaging
- {{ pin_subpackage('libfaiss', exact=True) }}
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
- mkl =2023.0 # [x86_64]
- python_abi <3.12
{% elif PY_VER == '3.12' %}
- mkl >=2023.2.0 # [x86_64 and not win]
- mkl =2023.1.0 # [x86_64 and win]
- python_abi =3.12
{% endif %}
test:
requires:
- numpy >=1.19,<2
- scipy
- pytorch <2.5
{% if PY_VER == '3.9' or PY_VER == '3.10' or PY_VER == '3.11' %}
- mkl =2023.0 # [x86_64]
- python_abi <3.12
{% elif PY_VER == '3.12' %}
- mkl >=2023.2.0 # [x86_64 and not win]
- mkl =2023.1.0 # [x86_64 and win]
- python_abi =3.12
{% endif %}
commands:
- python -X faulthandler -m unittest discover -v -s tests/ -p "test_*"
- python -X faulthandler -m unittest discover -v -s tests/ -p "torch_*"
- sh test_cpu_dispatch.sh # [linux64]
files:
- test_cpu_dispatch.sh # [linux64]
source_files:
- tests/