最近在玩faiss,运行这段代码的时候报错了:

res = faiss.StandardGpuResources()
flat_config = 0
index = faiss.GpuIndexFlatL2(res,d,flat_config)

报错内容见上:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "swigfaiss_gpu.py", line 2958, in __init__
this = _swigfaiss_gpu.new_GpuIndexFlatL2(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_GpuIndexFlatL2'.
Possible C/C++ prototypes are:
faiss::gpu::GpuIndexFlatL2::GpuIndexFlatL2(faiss::gpu::GpuResources *,faiss::IndexFlatL2 *,faiss::gpu::GpuIndexFlatConfig)
faiss::gpu::GpuIndexFlatL2::GpuIndexFlatL2(faiss::gpu::GpuResources *,faiss::IndexFlatL2 *)
faiss::gpu::GpuIndexFlatL2::GpuIndexFlatL2(faiss::gpu::GpuResources *,int,faiss::gpu::GpuIndexFlatConfig)
faiss::gpu::GpuIndexFlatL2::GpuIndexFlatL2(faiss::gpu::GpuResources *,int)

一开始怀疑是因为之前用conda安装过 faiss,索性conda uninstall faiss-gpu。卸载后还是报错。

找了半天也没找到资料。最后看了底层代码才解决。

既然解决了就分享给大家:

解决的方法是:

flat_config = faiss.GpuIndexFlatConfig()
flat_config.device = 0

index = faiss.GpuIndexFlatL2(res, d, flat_config)

原因是API接口有了变动,指定GPU卡号的方式不一样了。

另外:

安装faiss只要下载源码安装即可。不需要conda 安装Python版本。

安装的时候需要提前安装swig。

Faiss in python and GPU报错:NotImplementedError: Wrong number or type of arguments for overloaded function 'new_GpuIndexFlatL2'.的更多相关文章

  1. 【.NET调用Python脚本】C#调用python requests类库报错 'module' object has no attribute '_getframe' - IronPython 2.7

    最近在开发微信公众号,有一个自定义消息回复的需求 比如用户:麻烦帮我查询一下北京的天气? 系统回复:北京天气,晴,-℃... 这时候需要根据关键字[北京][天气],分词匹配需要执行的操作,然后去调用天 ...

  2. python pip install 报错TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' Command "python setup.py egg_info" failed with error code 1 in

    pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl ...

  3. 【python】python读取文件报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 2: illegal multibyte sequence

    python读取文件报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 2: illegal multibyte ...

  4. 【python】python安装tensorflow报错:python No matching distribution found for tensorflow==1.12.0

    python安装tensorflow报错:python No matching distribution found for tensorflow==1.12.0 python版本是3.7.2 要安装 ...

  5. mac下python环境pip报错[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) 的解决方法

    1.mac下python环境pip报错: issuserdeMacBook-Pro:~ issuser$ pip install pyinstallerCollecting pyinstaller  ...

  6. Django中修改DATABASES后,执行python manage.py ****报错!UnicodeEncodeError

    Django中修改DATABASES后,执行python manage.py ****报错!UnicodeEncodeError: 'latin-1' codec can't encode chara ...

  7. python 安装模块报错 response.py", line 302, in _error_catcher

    python 安装模块报错 Exception:Traceback (most recent call last): File "/usr/share/python-wheels/urlli ...

  8. 关于编译报错“dereferencing pointer to incomplete type...

    今天同事问了我一个问题,他make的时候报错,“第201行:dereferencing pointer to incomplete type”,我随即查阅了很多资料,也没看出个所以然.最后问题得到了解 ...

  9. 编译报错dereferencing pointer to incomplete type

    关于编译报错“dereferencing pointer to incomplete type... 多是没找到结构体的定义,可以在本地复制其定义试试. 参考: http://my.oschina.n ...

随机推荐

  1. spring4注解配置datasource方式

    package com.boot.config; import org.springframework.context.annotation.AnnotationConfigApplicationCo ...

  2. VUE路由携带参数的三种方式

    vue 通过路由在进行页面跳转时,会经常携带参数用于同步页面间的数据 路由中携带参数的方式总结如下: 路由定义示例: { name: 'list', path: '/list', component: ...

  3. 类似py2exe软件真的能保护python源码吗

    类似py2exe软件真的能保护python源码吗 背景 最近写了个工具用于对项目中C/C++文件的字符串常量进行自动化加密处理,用python写的,工具效果不错,所以打算在公司内部推广.为了防止代码泄 ...

  4. 怎样Debug Dynamics 365 CRM Plugin

    写了这么多期的随笔,很多人会问,怎么debug写好的plugin呢 首先我们需要准备以下内容 Visual Studio Plugin Registration Tool CRM Instance E ...

  5. Python连接Oracle数据查询导出结果

    python连接oracle,需用用到模块cx_oracle,可以直接pip安装,如网络不好,可下载离线后本地安装 cx_oracle项目地址:https://pypi.org/project/cx_ ...

  6. linux 管道通信

    下面举linux下有名管道通信的代码. ----------------------------------------- fifo_read.c =========== #include<er ...

  7. 【Algorithm】字符串编辑距离(Levenshtein距离)C++算法实现

    算法实现比较简单,但算法原理不明白,有空了再研究一下. unsigned LevenshteinDistance(const string& s1, const string& s2) ...

  8. MySQL面试题中:主从同步部署介绍

    主从同步部署1.两台相同版本的mysql数据库,一台做主库,一台从库 主库开启binlog 在配置文件中的[mysqld]模块中添加log-bin=mysql-bin和server-id=1,一定要保 ...

  9. nginx1.14.0版本https加密配置

    修改host文件,为最后访问域名准备 C:\Windows\System32\drivers\etc host文件目录192.168.10.140 www.joyce.com 在最后添加这个自定义域名 ...

  10. 将golang中变量重置为零的reflect方法

    下面给出简单的代码,这里通过将变量重置为零来实现过滤字段的目的: type student struct { Age int `json:"age,omitempty"` Name ...