【发布时间】:2020-06-18 20:19:24
【问题描述】:
我正在尝试在 Google Colab 上运行 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
有什么想法吗?
【问题讨论】:
标签: python python-3.x google-colaboratory