推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
t133
V2EX  ›  Python

torch 调用的 cpp 如何调试

  •  
  •   t133 · Sep 25, 2023 · 1842 views
    This topic created in 965 days ago, the information mentioned may be changed or developed.

    比如这个文件:
    https://github.com/activatedgeek/simplex-gp/blob/master/gpytorch_lattice_kernel/cpp/lattice.cpp
    似乎用 torch.utils.cpp_extension.load 他就会自动生成 so 然后载入成 python 的一个函数了 但是好像没法调试 c++内部的 code

    不太懂 c++,所以这个是怎么编译的 我试着写了个 makefile 感觉没法不使用 torch 编译出 so 文件
    更不用说调试这个 so 文件了
    我的理解是调用了 torch 和 pybind11 的头文件只要把 PATH 加到 cmake 的 flag 里就行了?

    2 replies    2023-09-25 05:41:45 +08:00
    ysc3839
        1
    ysc3839  
       Sep 25, 2023 via Android   ❤️ 1
    torch.utils.cpp_extension.load 后面的编译参数确保开启了调试符号。我不确定默认是否开启调试符号,也许默认开了就不需要动了。
    然后如果是类 Unix 平台,调试符号会被编译进动态库文件里面,用调试器给对应源代码文件下断点应该就能自动生效。
    如果是 Windows 平台,调试符号会是一个单独的 pdb 文件。一般来说 dll 里面会写入完整的 pdb 路径,调试器可以自动加载 pdb ,没有自动加载的话手动加载,然后下断点即可。
    t133
        2
    t133  
    OP
       Sep 25, 2023
    @ysc3839 非常感谢的确可以了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3119 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 13:02 · PVG 21:02 · LAX 06:02 · JFK 09:02
    ♥ Do have faith in what you're doing.