最近在玩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. 截取所有的winform runtime error

    https://stackify.com/csharp-catch-all-exceptions/ AppDomain.CurrentDomain.FirstChanceException += (s ...

  2. Comedi的安装

    1.comedi的安装:(需要注意的是comedi和comedilib安装顺序随意)    1.comedi与大多数2.2,2.4和2.6Linux内核配合使用,不支持2.6-2.6.6的内核,对2. ...

  3. skimage

    它是由python语言编写的,   子模块名称 主要实现功能 io 读取.保存和显示图片或视频 data 提供一些测试图片和样本数据 color 颜色空间变换 filters 图像增强.边缘检测.排序 ...

  4. numpy用法

    NumPy中创建特殊值 np.nan    np.inf nan表示数据空缺   inf表示无穷 参考:https://www.cnblogs.com/haoxi/p/9175781.html

  5. CSS奇淫技巧

    对于图标,使用fontsize设置大小,而非宽高! 高度不够的时候使用min-height 保持宽高比 四个方向的padding都是相对于 本盒子的宽度来的 常用于视频和图片的展示,比如轮播图. 所以 ...

  6. PageHelper 自动去掉排序参数问题

    PageHelper.startPage( req.getCurrent()   , req.getSize() ,"ordersCreateDate desc" ); 如果 上面 ...

  7. layui select配合input实现动态模糊搜索

    功能需求:select框可以自己输入,就是在下拉列表里找不到自己想要的选项就可以自己输入,同时还要支持模糊匹配功能 html代码: 样式: <style> .select-search-i ...

  8. 嵌入式GCC笔记

    GNU C Complier 查看 gcc 版本 :gcc -v 文件后缀名  .c的后缀 为C语言的文件源码 gcc  -o output gcc -o 输出文件名字 输入文件名 gcc -v -o ...

  9. Linux基础入门-文件系统操作与磁盘管理

    一.简单文件系统操作: df (-h) 查看磁盘容量: rootfs作为系统启动时内核载入内存之后,在挂载真正的磁盘之前的一个临时文件系统: /dev/sda2 对应主机硬盘的分区,后面的a表示第几块 ...

  10. H3C IRF MAD检测原理及相关问题验证

    一.IRF简介 IRF(Intelligent Resilient Framework,智能弹性架构)是H3C自主研发的软件虚拟化技术.它的核心思想是将多台设备通过IRF物理端口连接在一起,进行必要的 ...