126 lines
4.1 KiB
YAML
Raw Normal View History

# 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.8,<12" %}
{% set libcublas_constraints=">=11.11,<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 }}_raft{{ suffix }}"
run_exports:
- {{ pin_compatible('libfaiss', exact=True) }}
script_env:
- CUDA_ARCHS
requirements:
build:
- {{ compiler('cxx') }}
- sysroot_linux-64 # [linux64]
- llvm-openmp # [osx]
- cmake >=3.24.0
- make # [not win]
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- mkl =2023 # [x86_64]
- mkl-devel =2023 # [x86_64]
- cuda-toolkit {{ cudatoolkit }}
host:
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- mkl =2023 # [x86_64]
- openblas # [not x86_64]
- libraft =24.06
- cuda-version {{ cuda_constraints }}
run:
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- mkl =2023 # [x86_64]
- openblas # [not x86_64]
- cuda-cudart {{ cuda_constraints }}
- libcublas {{ libcublas_constraints }}
- libraft =24.06
- cuda-version {{ cuda_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-raft
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]
Fix faiss swig build with version > 4.2.x (#3315) Summary: Currently, faiss can't build with swig version > 4.2.x. As the https://github.com/facebookresearch/faiss/issues/3239 mentioned. Swig removed the support for 32bit https://github.com/swig/swig/commit/9fb3a4939e4ec528f050057d8ccd743a066222ac. So SWIGTYPE_p_unsigned_long_long isn't supported any more. In this diff, we are going to remove the unsupported type from Faiss swig. Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3315 Test Plan: STEP 1: create a new conda env ``` conda create --name faiss_swig conda activate faiss_swig ``` STEP 2: install dependecies from conda-forge ``` conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64=2.28 -c conda-forge ``` STEP 3: CMAKE ``` cmake -B build \ -DBUILD_TESTING=ON \ -DBUILD_SHARED_LIBS=ON \ -DFAISS_ENABLE_GPU=OFF \ -DFAISS_ENABLE_RAFT=OFF \ -DFAISS_OPT_LEVEL=avx512 \ -DFAISS_ENABLE_C_API=ON \ -DPYTHON_EXECUTABLE=$(which python) \ -DCMAKE_BUILD_TYPE=Release \ -DBLA_VENDOR=Intel10_64_dyn \ -DCMAKE_CUDA_FLAGS="-gencode arch=compute_75,code=sm_75" \ . ``` STEP 4: build ``` make -C build -j faiss && make -C build -j swigfaiss ``` <img width="876" alt="Screenshot 2024-03-25 at 12 24 16 AM" src="https://github.com/facebookresearch/faiss/assets/8333898/918f0caf-398a-4361-989f-93ff547cf2b2"> Reviewed By: algoriddle Differential Revision: D55304004 Pulled By: junjieqi fbshipit-source-id: e958009dc637aa33b0e1a574a16a846a4abb1525
2024-03-28 22:54:51 -07:00
- swig
- cmake >=3.24.0
- make # [not win]
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- mkl =2023 # [x86_64]
- cuda-toolkit {{ cudatoolkit }}
host:
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- python {{ python }}
- numpy >=1.19,<2
- {{ pin_subpackage('libfaiss', exact=True) }}
run:
- _openmp_mutex =4.5=2_kmp_llvm # [x86_64]
- python {{ python }}
- numpy >=1.19,<2
- packaging
- {{ pin_subpackage('libfaiss', exact=True) }}
test:
requires:
- numpy
- scipy
- pytorch
- 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/