东方耀AI技术分享

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 1559|回复: 1
打印 上一主题 下一主题

[学习笔记] Ubuntu18.04下pybind11的安装

[复制链接]

1365

主题

1856

帖子

1万

积分

管理员

Rank: 10Rank: 10Rank: 10

积分
14439
QQ
跳转到指定楼层
楼主
发表于 2021-4-20 10:35:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式



Ubuntu18.04下pybind11的安装
https://github.com/pybind/pybind11
C ++ 11和Python之间的无缝可操作性


首先安装cmake:http://www.ai111.vip/thread-977-1-1.html


查看版本:cmake --version
jiang@jiang-Ubuntu:~/GNU_Radio_works/gr-adapt-master$ cmake --version
cmake version 3.19.4


a.先下载pybind11的源代码:https://github.com/pybind/pybind11


b.进入pybind源代码,并建立新文件build,进行build,cmake,make..,具体如下:


cd 到pybind11目录
mkdir build
cd build
cmake ..
sudo make
sudo make install


如果不通过源码编译的方式安装:
sudo apt-get install python-pybind11


  1. jiang@jiang-Ubuntu:~/downloads/pybind11-master/build$ sudo make install
  2. [  4%] Built target pybind11_cross_module_tests
  3. [ 95%] Built target pybind11_tests
  4. [100%] Built target cross_module_gil_utils
  5. Install the project...
  6. -- Install configuration: "MinSizeRel"
  7. -- Installing: /usr/local/include/pybind11
  8. -- Installing: /usr/local/include/pybind11/cast.h
  9. -- Installing: /usr/local/include/pybind11/numpy.h
  10. -- Installing: /usr/local/include/pybind11/gil.h
  11. -- Installing: /usr/local/include/pybind11/buffer_info.h
  12. -- Installing: /usr/local/include/pybind11/common.h
  13. -- Installing: /usr/local/include/pybind11/eval.h
  14. -- Installing: /usr/local/include/pybind11/iostream.h
  15. -- Installing: /usr/local/include/pybind11/complex.h
  16. -- Installing: /usr/local/include/pybind11/functional.h
  17. -- Installing: /usr/local/include/pybind11/pytypes.h
  18. -- Installing: /usr/local/include/pybind11/chrono.h
  19. -- Installing: /usr/local/include/pybind11/attr.h
  20. -- Installing: /usr/local/include/pybind11/stl.h
  21. -- Installing: /usr/local/include/pybind11/detail
  22. -- Installing: /usr/local/include/pybind11/detail/class.h
  23. -- Installing: /usr/local/include/pybind11/detail/type_caster_base.h
  24. -- Installing: /usr/local/include/pybind11/detail/common.h
  25. -- Installing: /usr/local/include/pybind11/detail/init.h
  26. -- Installing: /usr/local/include/pybind11/detail/internals.h
  27. -- Installing: /usr/local/include/pybind11/detail/descr.h
  28. -- Installing: /usr/local/include/pybind11/detail/typeid.h
  29. -- Installing: /usr/local/include/pybind11/eigen.h
  30. -- Installing: /usr/local/include/pybind11/options.h
  31. -- Installing: /usr/local/include/pybind11/pybind11.h
  32. -- Installing: /usr/local/include/pybind11/embed.h
  33. -- Installing: /usr/local/include/pybind11/stl_bind.h
  34. -- Installing: /usr/local/include/pybind11/operators.h
  35. -- Installing: /usr/local/share/cmake/pybind11/pybind11Config.cmake
  36. -- Installing: /usr/local/share/cmake/pybind11/pybind11ConfigVersion.cmake
  37. -- Installing: /usr/local/share/cmake/pybind11/FindPythonLibsNew.cmake
  38. -- Installing: /usr/local/share/cmake/pybind11/pybind11Common.cmake
  39. -- Installing: /usr/local/share/cmake/pybind11/pybind11Tools.cmake
  40. -- Installing: /usr/local/share/cmake/pybind11/pybind11NewTools.cmake
  41. -- Installing: /usr/local/share/cmake/pybind11/pybind11Targets.cmake
  42. jiang@jiang-Ubuntu:~/downloads/pybind11-master/build$
复制代码








让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

1365

主题

1856

帖子

1万

积分

管理员

Rank: 10Rank: 10Rank: 10

积分
14439
QQ
沙发
 楼主| 发表于 2021-4-20 16:01:09 | 只看该作者
Tensorflow已经从SWIG切到pybind11了

个人比较喜欢/偏向于pybind11,有以下几个原因1. 灵活性:pybind11本质上还是在C API外面包了一层C++(或者说利用C++的元编程能力批量产生binding)所以可定制性很好,尤其是面向我这种有非主流需求的用户。2. 抽象能力:cython这种Python的补丁抽象能力没有完整的C++好,对于一个倾向于只让Python成为傻瓜式接口的人,我更希望能够同时在C++层面有丰富的抽象来方便developer。3. 生态:pybind11现在有很多基于它的生态,例如xtensor,Python/C++里最好的多维数组没有之一。然后还有pythran这个transpiler,可以把Python的prototype转到C++,一定程度上减轻编写C++的蛋疼点。PS. 我觉得有了pythran以后cython已经没有任何优势了
让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|人工智能工程师的摇篮 ( 湘ICP备2020019608号-1 )

GMT+8, 2024-5-22 11:22 , Processed in 0.162747 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表