Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined reference to GPU symbols when compiling 1.9.0 #4132

Open
vcampmany opened this issue Jan 22, 2025 · 5 comments
Open

Undefined reference to GPU symbols when compiling 1.9.0 #4132

vcampmany opened this issue Jan 22, 2025 · 5 comments
Assignees
Labels

Comments

@vcampmany
Copy link

I compiled FAISS 1.9.0 from source following the instructions in INSTALL.md. Compilation is successful, however when I link the library to my application, I get undefined reference to GPU symbols. Until now, I've been using FAISS 1.7.3 in my C++ application without problems. The problem only came when trying to upgrade to 1.9.0.

I've been trying to find the root cause but I haven't been successful so far. Here is what I found out on the way.

First, this is how I'm compiling the library:

cmake -B build . -DFAISS_ENABLE_GPU=ON -DFAISS_ENABLE_PYTHON=OFF -DCUDAToolkit_ROOT=/usr/local/cuda -DCMAKE_CUDA_ARCHITECTURES=75 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
make -C build -j faiss

This generates a libfaiss.a file for both 1.9.0 and 1.7.3. However, the symbols have changed, 1.9.0 having only one "gpu" symbol after grep. here the results

  • For 1.9.0
$ nm libfaiss.a | grep gpu
0000000000000000 B _ZN5faiss19gpu_compile_optionsB5cxx11E
  • For 1.7.3
$ nm libfaiss.a | grep gpu
                 U _ZN5faiss3gpu13GpuIndexIVFPQ19setPrecomputedCodesEb
                 U _ZN5faiss3gpu16getMaxKSelectionEv
0000000000000380 T _ZN5faiss3gpu17GpuParameterSpace10initializeEPKNS_5IndexE
0000000000000010 t _ZN5faiss3gpu17GpuParameterSpace10initializeEPKNS_5IndexE.cold
0000000000000000 W _ZN5faiss3gpu17GpuParameterSpaceD0Ev
0000000000000000 W _ZN5faiss3gpu17GpuParameterSpaceD1Ev
0000000000000000 W _ZN5faiss3gpu17GpuParameterSpaceD2Ev
0000000000000000 n _ZN5faiss3gpu17GpuParameterSpaceD5Ev
                 U _ZNK5faiss3gpu11GpuIndexIVF11getNumListsEv
0000000000000000 T _ZNK5faiss3gpu17GpuParameterSpace19set_index_parameterEPNS_5IndexERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEd
0000000000000000 t _ZNK5faiss3gpu17GpuParameterSpace19set_index_parameterEPNS_5IndexERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEd.cold
                 U _ZTIN5faiss3gpu11GpuIndexIVFE
                 U _ZTIN5faiss3gpu13GpuIndexIVFPQE
0000000000000000 V _ZTIN5faiss3gpu17GpuParameterSpaceE
0000000000000000 V _ZTSN5faiss3gpu17GpuParameterSpaceE
0000000000000000 V _ZTVN5faiss3gpu17GpuParameterSpaceE
00000000000009d0 T _ZN5faiss3gpu11ToCPUCloner11clone_IndexEPKNS_5IndexE
0000000000000026 t _ZN5faiss3gpu11ToCPUCloner11clone_IndexEPKNS_5IndexE.cold
0000000000000730 T _ZN5faiss3gpu11ToCPUCloner11merge_indexEPNS_5IndexES3_b
0000000000000000 W _ZN5faiss3gpu11ToCPUClonerD0Ev
0000000000000000 W _ZN5faiss3gpu11ToCPUClonerD1Ev
0000000000000000 W _ZN5faiss3gpu11ToCPUClonerD2Ev
0000000000000000 n _ZN5faiss3gpu11ToCPUClonerD5Ev
00000000000001f0 T _ZN5faiss3gpu11ToGpuCloner11clone_IndexEPKNS_5IndexE
....
....
....
(The list continues, shorten it for verbosity)

The absence of "gpu" symbols in 1.9.0 could explain why I'm getting undefined references in my application. Did anyone face this issue or am I doiong something wrong? Your help would be much appreciated. Thank you 🙁

@mnorris11 mnorris11 self-assigned this Feb 14, 2025
@mnorris11
Copy link

Hi @vcampmany , sorry for the slow reply

What is your cuda version?

Our CI is building cudatoolkit 12.4

@vcampmany
Copy link
Author

Hi @mnorris11 , thanks for your reply. I am also using CUDA 12.4

@mnorris11
Copy link

@vcampmany

  1. When you say 1.7.3 and 1.9.0, did you download the source for these versions and then cmake them? Does installing the package itself like conda install faiss-cpu not work?

  2. Was cuda installed in a conda environment?

The cmake steps for our CI installs it via conda. The steps are at https://github.com/facebookresearch/faiss/blob/main/.github/actions/build_cmake/action.yml#L35-L137.

@vcampmany
Copy link
Author

@mnorris11

  1. Yes, I downloaded the sources and compiled from source with CMake. I haven't tried conda we are only using FAISS C++ so we've always compiled FAISS from source and linked it against our project. That still works with 1.9.0. However, the generated static library doesn't have GPU symbols

  2. No, CUDA was installed following the runfile instructions in the official documentation

@mnorris11
Copy link

@mnorris11

  1. Yes, I downloaded the sources and compiled from source with CMake. I haven't tried conda we are only using FAISS C++ so we've always compiled FAISS from source and linked it against our project. That still works with 1.9.0. However, the generated static library doesn't have GPU symbols
  2. No, CUDA was installed following the runfile instructions in the official documentation

@vcampmany

  1. If you can't install cuda in a conda environment, does 1.10.0 have the same problem?
  2. If you set VERBOSE=1 during cmake, do you see --whole-archive?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants