# GDB attach debug TVM

**URL:** <https://discuss.tvm.apache.org/t/gdb-attach-debug-tvm/14870>\
**Category:** Troubleshooting\
**Created:** [May 5, 2023, 4:43am UTC](https://discuss.tvm.apache.org/t/gdb-attach-debug-tvm/14870 "2023-05-05T04:43:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guoriyue](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/guoriyue/32/4742_2.png) [@guoriyue](https://discuss.tvm.apache.org/u/guoriyue)\
**Post date:** [May 5, 2023, 4:43am UTC](https://discuss.tvm.apache.org/t/gdb-attach-debug-tvm/14870/1 "2023-05-05T04:43:15Z")

</div>

I was hoping you could assist me with a couple of questions regarding debugging the quantization part of TVM using a Python script and GDB attach. Specifically, I have the following questions:

1. Does the quantization process call functions in src/relay/quantize?
2. Since I am uncertain which part of TVM the quantization process calls, I would like to debug a known issue in order to test whether GDB attach is working properly.

```auto

One or more operators have not been tuned. Please tune your model for better performance. Use DEBUG logging level to see more details.
[18:24:11] /home/ubuntu/mxnet/src/io/iter_image_recordio_2.cc:180: ImageRecordIOParser2: /home/ubuntu/.tvm_test_data/val_256_q90.rec, use 4 threads for decoding..
[18:24:11] /home/ubuntu/mxnet/src/storage/storage.cc:202: Using Pooled (Naive) StorageManager for CPU_PINNED
Traceback (most recent call last):
  File "/home/ubuntu/scripts/compile_quant_pytorch.py", line 160, in <module>
    quant_tvm_model = graph_executor.GraphModule(lib["default"](dev))
  File "/home/ubuntu/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
    raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
  5: TVMFuncCall
  4: tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::GraphExecutorFactory::GetFunction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tvm::runtime::ObjectPtr<tvm::runtime::Object> const&)::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
  3: tvm::runtime::GraphExecutorFactory::ExecutorCreate(std::vector<DLDevice, std::allocator<DLDevice> > const&)
  2: tvm::runtime::GraphExecutor::Init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tvm::runtime::Module, std::vector<DLDevice, std::allocator<DLDevice> > const&, tvm::runtime::PackedFunc)
  1: tvm::runtime::GraphExecutor::SetupOpExecs()
  0: tvm::runtime::GraphExecutor::CreateTVMOp(tvm::runtime::TVMOpParam const&, std::vector<DLTensor, std::allocator<DLTensor> > const&)
  File "/home/ubuntu/tvm/src/runtime/graph_executor/graph_executor.cc", line 585
TVMError: 
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
  Check failed: (pf != nullptr) is false: no such function in module: quantize_inputs

```

I set a breakpoint on line 585 in the file /home/ubuntu/tvm/src/runtime/graph\_executor/graph\_executor.cc. However, it seems that the code does not pause at that point and instead raises get\_last\_ffi\_error(). Is function actually called in the Python script graph\_executor.GraphModule?

Thank you in advance for your help!

---

<div class="post-metadata">

**Author:** ![elenkalda-arm](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/e/ee59a6/32.png) [@elenkalda-arm](https://discuss.tvm.apache.org/u/elenkalda-arm)\
**Post date:** [May 5, 2023, 10:40am UTC](https://discuss.tvm.apache.org/t/gdb-attach-debug-tvm/14870/2 "2023-05-05T10:40:24Z")

</div>

Are you using a debug build of TVM? That is, the `CMAKE_BUILD_TYPE` has to be set to `Debug` for gdb to work properly with TVM…

---

<div class="post-metadata">

**Author:** ![guoriyue](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/guoriyue/32/4742_2.png) [@guoriyue](https://discuss.tvm.apache.org/u/guoriyue)\
**Post date:** [May 6, 2023, 1:24am UTC](https://discuss.tvm.apache.org/t/gdb-attach-debug-tvm/14870/3 "2023-05-06T01:24:05Z")

</div>

Yes, need to build with -DCMAKE\_BUILD\_TYPE=Debug. Thanks so much for your help! 😭
