Build Faiss with MKL on Ubuntu Link to heading

Faiss’ documentation on installing from source is not so helpful when it comes to using MKL. With some effort on searching the web, I got it to work finally

# install MKL
# https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-download.html?operatingsystem=linux&distributions=aptpackagemanager
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt update
sudo apt install intel-oneapi-mkl

# set MKL variables
source /opt/intel/oneapi/setvars.sh

# clone faiss
git clone https://github.com/facebookresearch/faiss.git

# build
cd faiss
cmake -DBUILD_SHARED_LIBS=ON -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF -DFAISS_ENABLE_C_API=ON -Bbuild
make -Cbuild -j

Reference: https://stackoverflow.com/questions/58666921/how-to-set-mkl-on-linux-with-cmake