Hi Everyone,
I am a Phd Student in South Korea and i am tasked to implement efficient message passing graph learning kernel for one of our lab project. from past few weeks i am reading DGL documents and reading the code. However, I I am facing difficulties understanding the src code in C for message passing APIs. I have also cloned the DGL github repository and is debugging the code line by line but i get stuck on the CAPI (C APIs). I would appreciate help for how to debug c code after the C wrappers called in python, Plus is there a way to run the c code in debug ? where currently it is called from dll? and any more helping material for understanding message passing will be really appreciated. Thanks in advance
Hi @tariqaf, to debug C code warped, I recommend to use GDB as debugging tool , refer GDB for python for python side debugging. And you need to build DGL like this:
- Install DGL from source. And add CMAKE_BUILD_TYPE=DEBUG when building cmake files. E.g. CUDA debug build
cmake -DUSE_CUDA=ON -DCMAKE_BUILD_TYPE=DEBUG ..
- Set envs to use self-built lib:
export DGL_HOME=/path/to/your/dgl/clone
export DGL_LIBRARY_PATH=$DGL_HOME/build
export PYTHONPATH=$PYTHONPATH:$DGL_HOME/python
cd python
python setup.py build_ext --inplace
Details can be found here, refer Building and Testing section.
Below is a simple live debugging process, add it here for your reference.
python code → test.py
...
dgl.load_graphs('graphs_t.bin')
C code
load_graphs call GetFileVersion() function in graph_serialize.cc
Steps
- Enter into gdb python mode
gdb python
- Set breakpoint
b GetFileVersion
or
b graph_serialize.cc:122
- run your script
r test.py
- Look up info, use bt to make sure you entered C code:
bt
And after that, you can use other gdb commands for debugging.
This is very helpful. Thank you so much for the guidance. I will now try the same for setting the code and learn by debugging. Again Thank you so much.
Hi @a651694192,
sorry for inconvienience. I have followed all the steps for Install DGL from source. where i first forked the DGL and clone the forked repository as mentioned. After that i created build directory and call the same cmake command within build directory. After that using visual studio 17 2022 i compiled the dgl.sln and it builded sucessfully. After that when i call the setup.py install in python folder it gives warning that cython is not supported by windows, however it compiled but after that when i import dgl it says module not found? i think it is still not build and i dont know what i am doing wrong? maybe cython is must? or maybe python wrappers dont find the c build folder? i dont know what i am doing wrong here. i am surely doing some silly mistake over here.
It looks your C lib has been built successfully but python installation failed, thus import DGL doesn’t work. For Cpython, you need to install it with the same compiler as python(Cpython install).
I suggest you uninstall everything firtst(DGL, Cpython or even python), and then reinstall them following official guide using same tools(VS2019 x64 Native tools recommend here)
Thanks it worked as you suggested. Previously i was running python 3.10 and vs 17 2022. Thanks again
Does this work for visual studio code in window if i installed gdb using minGW? i am trying but facing some issues? sorry again for any incovience.
VS code now support minGW compile and gdb, so it should be supported. Refer Get Started with C++ and Mingw-w64 in Visual Studio Code for more information.
Thank You so much… I am following the link you mentioned.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.