CMake's error happened while I was trying to configure raft.
weiwch opened this issue · 6 comments
Summary
Platform
OS: Ubuntu 20.04.6 LTS
Faiss version: Both af70c5b (latest main branch now) and v1.9.0 are experiencing the same issue
Installed from: compilation
Faiss compilation options:
cmake -B _build \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTING=OFF \
-DFAISS_OPT_LEVEL=avx2 \
-DFAISS_ENABLE_GPU=ON \
-DFAISS_ENABLE_RAFT=ON \
-DCMAKE_CUDA_ARCHITECTURES=86 \
-DFAISS_ENABLE_PYTHON=OFF \
-DBLA_VENDOR=Intel10_64lp \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE=Release .
(It's almost identical to conda/faiss-gpu-raft/build-lib.sh
,I only changed DFAISS_OPT_LEVEL to avx2 and filled in DCMAKE_CUDA_ARCHITECTURES.)
Running on:
- CPU
- GPU
Interface:
- C++
- Python
Reproduction instructions
When I execute the cmake command with FAISS_ENABLE_RAFT=ON
, I receive the following error. The error is a result of a warning in CMakeLists.txt:83 that fails to find raft. This issue is present in both the latest main and the commit tagged as 1.9.0.
cmake -B _build -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DFAISS_OPT_LEVEL=avx2 -DFAISS_ENABLE_GPU=ON -DFAISS_ENABLE_RAFT=ON -DCMAKE_CUDA_ARCHITECTURES=86 -DFAISS_ENABLE_PYTHON=OFF -DBLA_VENDOR=Intel10_64lp -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release .
-- The CXX compiler identification is GNU 9.4.0
-- The CUDA compiler identification is NVIDIA 11.8.89
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda-11.8/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
CMake Warning at CMakeLists.txt:83 (find_package):
By not providing "Findraft.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "raft", but
CMake did not find one.
Could not find a package configuration file provided by "raft" with any of
the following names:
raftConfig.cmake
raft-config.cmake
Add the installation prefix of "raft" to CMAKE_PREFIX_PATH or set
"raft_DIR" to a directory containing one of the above files. If "raft"
provides a separate development package or SDK, be sure it has been
installed.
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Could NOT find MKL (missing: MKL_LIBRARIES)
-- Looking for sgemm_
-- Looking for sgemm_ - found
-- Found BLAS: /opt/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_intel_lp64.so;/opt/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_intel_thread.so;/opt/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_core.so;/opt/intel/oneapi/compiler/2023.2.0/linux/compiler/lib/intel64_lin/libiomp5.so;-lpthread;-lm;-ldl
-- Looking for cheev_
-- Looking for cheev_ - found
-- Found LAPACK: /opt/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_intel_lp64.so;/opt/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_intel_thread.so;/opt/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_core.so;/opt/intel/oneapi/compiler/2023.2.0/linux/compiler/lib/intel64_lin/libiomp5.so;-lpthread;-lm;-ldl;-lpthread;-lm;-ldl
-- Found CUDAToolkit: /usr/local/cuda-11.8/include (found version "11.8.89")
-- Configuring done (7.2s)
CMake Error at faiss/gpu/CMakeLists.txt:336 (target_link_libraries):
Target "faiss_gpu" links to:
raft::raft
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
-- Generating done (0.1s)
CMake Generate step failed. Build files cannot be regenerated correctly.
Additionally, I found a issue that does not affect the program's compilation. If I set -DBLA_VENDOR=Intel10_64lp (or other valid values), cmake/FindMKL.cmake is unable to find MKL, but it is still able to link against the required BLAS libraries as shown above. However, if I leave DBLA_VENDOR empty, MKL is found normally. The log shows:
-- Found MKL: /opt/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_intel_lp64.so;/opt/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_sequential.so;/opt/intel/oneapi/mkl/2023.2.0/lib/intel64/libmkl_core.so;-lpthread;-lm;-ldl
I'd like to correct my previous statement about the additional MKL issue. In my case, setting DBLA_VENDOR is necessary, despite the log showing Could NOT find MKL
, in order to link iomp5. Without it, libfaiss will use gomp, leading to a significant performance drop, as observed in my testing. Given that this problem does affect the program's performance, I'm wondering if I should open a new issue to report this.
There is an ongoing CMake RAFT issue: #3925 (comment). Nvidia folks are working on pinpointing the issue.
Hi @weiwch , what is your conda environment setup? This looks like a different error than the ongoing CMake RAFT issue.
Hi @mnorris11 !
I'm not using any conda environment, I'm just calling cmake to configure and generate the makefile, which should be unrelated to conda. I tried with an empty conda environment, but the error remains the same.
However, when I try to run it in a conda environment where raft is already installed, the configure process seems to resolve the error, but I get an error during the make process, which might be due to my raft version being 24.08 causing a compilation error. I'll try with 24.06 later.
However, it's worth noting that the find_package(raft COMPONENTS compiled distributed)
( CMakeLists.txt:83 ) step enters the file /home/<my_user_name>/miniconda3/envs/raft/lib/cmake/raft/raft-config-version.cmake
, which is the installed file of raft. According to the RAFT documentation (https://github.com/rapidsai/raft/blob/branch-24.06/docs/source/build.md#using-raft-c-in-downstream-projects), which has a similar CMakelist (https://github.com/rapidsai/raft/tree/HEAD/cpp/template), when building downstream projects, all dependencies are installed in build/_deps
and not rely on the already installed raft. Should faiss use the pre-installed RAFT during its build process?
Sorry for the delay;
To build from source, you would have to set up the conda environment first. If you're building from source, you should not need RAFT installed in conda.
Try:
- Download latest miniconda: https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh (or x86_64 depending on your architecture, the installer will give an warning if it is wrong)
conda remove --name faiss_env --all -y
# in case there's an existing oneconda create -n faiss_env
conda activate faiss_env
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 gflags
which python3
# should print somewhere like miniconda3/bin/python3 now, instead of your system's python3- then try your cmake
Edit: btw, Nvidia folks are working on replacing RAFT with cuVS. You can follow their PR at #3549. From https://github.com/rapidsai/raft:
The vector search and clustering algorithms in RAFT are being migrated to a new library dedicated to vector search called cuVS. We will continue to support the vector search algorithms in RAFT during this move, but will no longer update them after the RAPIDS 24.06 (June) release. We plan to complete the migration by RAPIDS 24.10 (October) release and will be removing them altogether in the 24.12 (December) release.
I followed your steps exactly, but it still didn't work. However, I have now resolved the issue by installing raft via conda.