How to install faiss in python
It is stated that faiss does not support winsows for the time being, supports mac, linux
When I joined a team to study "Recommendation System Introduction Practice: News Recommendation Prediction" organized by Datawhale in November, I needed to import a database called faiss for multi-channel recall tasks. So Baidu inquired various methods and stepped on various pits. . Finally step on the pit to cry, you can make a USB boot disk or install a virtual machine
faiss introduction
Faiss is an open source search library for clustering and similarity by the Facebook AI team. It provides efficient similarity search and clustering for dense vectors, supports search for billions of vectors, and is currently the most mature approximate nearest neighbor search library. It contains a variety of algorithms for searching vector sets of any size (note: the size of the vector set is determined by RAM memory), as well as supporting codes for algorithm evaluation and parameter adjustment. Faiss is written in C++ and provides a Python interface that perfectly connects with Numpy. In addition, GPU implementations are provided for some core algorithms. Through the introduction of Faiss document, we can understand that the main function of faiss is similarity search. As shown in the figure below, taking picture search as an example, the so-called similarity search is to find the K pictures most similar to the target I specified in a given pile of pictures, also referred to as the KNN (K nearest neighbor) problem. All blog formalism nonsense. What can't you do, the first place for dry rice
Anaconda and pycharm installation
Needless to say, Anaconda and pycharm are one of the first choices for Python programming. It provides a good interface and integrated environment. If you don't know, you can search on the Internet. Anyway, you can use it without thinking.
This step
You can download it from windows, but you have to download a copy of the linux version to ubantu, which is troublesome. I have a dual system, no virtual machine is installed, because the virtual machine runs slowly, and then stepped on the nuclear bomb. . By default, emptying the entire disk will wipe out my entire mechanical hard drive. This is omitted here. Most of the online tutorials are how to write a simple tutorial like a doctoral dissertation. The blog is not recommended again.
Anaconda download address
Pycharm installation
pycharm download address It is
recommended to eat the pro version, don’t change my old watch . I was also a popular version before, but later I found that the pro version is really fragrant. It is a necessary variable for getting started python analysis code. The link is as follows . If you are a student, you can apply for free. Of course, I am too. It is troublesome. Wechat search the public number python alliance to reply jihuoma collection code . It seems that the blog post cannot be published for this reason. Solemnly declare that I did not advertise, if you have other methods. .
First decompress the downloaded compressed package, then find the bin file in the decompressed pycharm, and then right click -> open in the terminal.
carried out
sh pycharm.sh
bash pycharm.sh
Remember that you cannot see the pychram.sh file in the bin file, but this command can be executed under the bin path
Anaconda
If the download is slow, copy the link to download in Xunlei, the Internet speed of the Xunlei download server outside the country is still quite fast
Please pay attention to downloading the Tsinghua source link, please click on the datetime above to download the latest version, otherwise you will cry like me
tab completion
bash Anaconda3-5.2.0-Linux-x86_64.sh
Go to the anaconda path and execute the package you downloaded. We kindly remind us that the package version is different. You have to enter the name of the package you downloaded anaconda.
conda update all
Reported an error to me and reported a URL, I thought it was a problem with my source, and then ran
Add sources to speed up the download speed of the installation package, or you will see your touching download speed
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
Can't update.
If you want to switch back to the default source, use the command
conda config --remove-key channels
Later, I stepped on the pit again. It was too difficult for me to update pip,
which resulted in some packages not being downloaded.
pip install --upgrade pip -i https://pypi.douban.com/simple
-i plus source url
example
pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install numpy -i http://pypi.douban.com/simple
Other packages are also fine, remember that pip uses your python compiler, and conda is the compiler in anconda environment. . Pycharm personally thinks that using the python compiler under anaconda, anconda integrates many packages of python.
Anaconda install and update package instructions
conda install package
conda update package
faiss installation
Terminal execution
conda install faiss-cpu -c pytorch
conda install faiss-gpu cudatooklkit=10.0 -c pytorch
Congratulations you're done