Skip to content

Commit 0d4aedf

Browse files
junjieqiabhinavdangeti
authored andcommitted
Fix faiss swig build with version > 4.2.x (facebookresearch#3315)
Summary: Currently, faiss can't build with swig version > 4.2.x. As the facebookresearch#3239 mentioned. Swig removed the support for 32bit swig/swig@9fb3a49. 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: facebookresearch#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
1 parent 1eae3dd commit 0d4aedf

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ jobs:
224224
- run:
225225
name: Install env using main channel
226226
command: |
227-
conda install -y -q python=3.11 cmake make swig=4.0.2 mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64
227+
conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64=11.2 sysroot_linux-64
228228
- when:
229229
condition:
230230
equal: [ "ON", << parameters.raft >> ]
231231
steps:
232232
- run:
233233
name: Install env using conda-forge channel
234234
command: |
235-
conda install -y -q python=3.11 cmake make swig=4.0.2 mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64 sysroot_linux-64=2.28 libraft cuda-version=11.8 cuda-toolkit -c rapidsai-nightly -c "nvidia/label/cuda-11.8.0" -c conda-forge
235+
conda install -y -q python=3.11 cmake make swig mkl=2023 mkl-devel=2023 numpy scipy pytest gxx_linux-64=11.2 sysroot_linux-64=2.28 libraft cuda-version=11.8 cuda-toolkit -c rapidsai-nightly -c "nvidia/label/cuda-11.8.0" -c conda-forge
236236
- when:
237237
condition:
238238
and:

conda/faiss-gpu-raft/meta.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ outputs:
8484
build:
8585
- {{ compiler('cxx') }}
8686
- sysroot_linux-64 =2.17 # [linux64]
87-
- swig =4.0.2
87+
- swig
8888
- cmake >=3.23.1
8989
- make # [not win]
9090
host:

faiss/python/swigfaiss.swig

+2-2
Original file line numberDiff line numberDiff line change
@@ -1022,14 +1022,14 @@ PyObject *swig_ptr (PyObject *a)
10221022
return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0);
10231023
}
10241024
if(PyArray_TYPE(ao) == NPY_UINT64) {
1025-
#ifdef SWIGWORDSIZE64
1025+
#if (__SIZEOF_LONG__ == 8)
10261026
return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0);
10271027
#else
10281028
return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0);
10291029
#endif
10301030
}
10311031
if(PyArray_TYPE(ao) == NPY_INT64) {
1032-
#ifdef SWIGWORDSIZE64
1032+
#if (__SIZEOF_LONG__ == 8)
10331033
return SWIG_NewPointerObj(data, SWIGTYPE_p_long, 0);
10341034
#else
10351035
return SWIG_NewPointerObj(data, SWIGTYPE_p_long_long, 0);

0 commit comments

Comments
 (0)