问题描述
我已经安装了faiss。但是,当我尝试导入时,会引发以下错误。
ModuleNotFoundError: No module named 'faiss.swigfaiss_avx2'
但是我可以使用以下语句将其导入
python -c "import faiss,numpy
faiss.Kmeans(10,20).train(numpy.random.rand(1000,10).astype('float32'))"
我该如何解决?
解决方法
如果您使用pip install faiss
在CPU上安装了faiss,请尝试以下操作:
pip uninstall faiss
pip install faiss-cpu
或使用conda:
conda install -c pytorch faiss-cpu