Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Google Colaboratory上运行faiss_Python_Python 3.x_Google Colaboratory - Fatal编程技术网

Python 在Google Colaboratory上运行faiss

Python 在Google Colaboratory上运行faiss,python,python-3.x,google-colaboratory,Python,Python 3.x,Google Colaboratory,我试图在GoogleColab上运行Faiss的简单示例,但仍会导致内核崩溃并重新启动。 日志中的错误是: 英特尔MKL致命错误:无法加载libmkl_avx2.so或libmkl_def.so。 当同时使用CPU或GPU版本时会发生这种情况。 下面是我在Google collab上安装Faiss的方式 !wget https://anaconda.org/pytorch/faiss-cpu/1.5.1/download/linux-64/faiss-cpu-1.5.1-py36h6bb024

我试图在GoogleColab上运行Faiss的简单示例,但仍会导致内核崩溃并重新启动。 日志中的错误是: 英特尔MKL致命错误:无法加载libmkl_avx2.so或libmkl_def.so。 当同时使用CPU或GPU版本时会发生这种情况。 下面是我在Google collab上安装Faiss的方式

!wget  https://anaconda.org/pytorch/faiss-cpu/1.5.1/download/linux-64/faiss-cpu-1.5.1-py36h6bb024c_1.tar.bz2
!tar xvjf faiss-cpu-1.5.1-py36h6bb024c_1.tar.bz2
!cp -r lib/python3.6/site-packages/* /usr/local/lib/python3.6/dist-packages/
!pip install mkl
我尝试运行的代码是:

 import numpy as np
    d = 64                           # dimension
    nb = 100000                      # database size
    nq = 10000                       # nb of queries
    np.random.seed(1234)             # make reproducible
    xb = np.random.random((nb, d)).astype('float32')
    xb[:, 0] += np.arange(nb) / 1000.
    xq = np.random.random((nq, d)).astype('float32')
    xq[:, 0] += np.arange(nq) / 1000

import faiss                   # make faiss available
index = faiss.IndexFlatL2(d)   # build the index
print(index.is_trained)
index.add(xb)                  # add vectors to the index
print(index.ntotal)

k = 4                          # we want to see 4 nearest neighbors
D, I = index.search(xb[:5], k) # sanity check
print(I)
print(D)
D, I = index.search(xq, k)     # actual search
print(I[:5])                   # neighbors of the 5 first queries
print(I[-5:])  
坠机发生在这条线路上

D, I = index.search(xq, k)     # actual search

有什么想法吗?

适合我的解决方案:

!apt install libomp-dev
!python -m pip install --upgrade faiss faiss-gpu
import faiss
我从你那里得到了这个密码