Cmake variables error when installing faiss-gpu

I’m order to install faiss-gpu, I first needed to install cmake and did it by cloning the cmake repo from GitHub - Kitware/CMake: Mirror of CMake upstream repository and running

./bootstrap && make && make install

Then to install faiss-gpu I cloned the following repo GitHub - facebookresearch/faiss: A library for efficient similarity search and clustering of dense vectors. Once cloned I changed directory into that folder and ran the following:

cmake -B build . && make -C -j faiss

But I get multiple errors related to environment variables not set such as:

CMake Error at /usr/local/share/cmake-3.27/Modules/CMakeDetermineCUDACompiler.cmake:603 (message):
  Failed to detect a default CUDA architecture.
 
 
 
  Compiler output:
 
Call Stack (most recent call first):
  CMakeLists.txt:62 (enable_language)
 
 
-- Configuring incomplete, errors occurred!
 

After doing some research I found this as a possible solution, so I did the following:

cmake . -DCMAKE_CUDA_ARCHITECTURES=52 61 -DTARGET_NAME=tgt

Then the next error is that there is a missing variable: _CMAKE_CUDA_WHOLE_FLAG

Read above as described in detail.

Cc: @robert.maynard

Delete your build directory, and explicitly specify that you wish to use nvcc as your CUDA compiler. CMake is trying to use clang as the CUDA compiler and failing.

This would roughly look like:

CUDACXX=/path/to/nvcc cmake -S <faiss-gpu/src/dir> -B <faiss-gpu/build/dir>