How to Build Tensorflow Debug Version

I would like to fully understand Tensorflow mechanisms. To complete the task, I would like to build a debug library of Tensorflow 2.4, write a program using Tensorflow’s C++ API, link my object files to the Tensorflow debug library and debug the program using gdb/cuda-gdb. Can I get specific steps of building the debug library that can be used to fulfill my purpose?

2 Likes

https://tensorflow-prod.ospodiscourse.com/t/what-is-the-best-approach-to-debug-in-tensorflow-when-working-with-the-c-code-base/468

I just viewed the discussion, and navigated to the following document: tensorflow/CONTRIBUTING.md at master · tensorflow/tensorflow · GitHub. In the document, it is pointed out that " the --config=dbg option is not officially supported".

I used the following command to build the source code of v2.4: “bazel build --config=cuda --config=dbg //tensorflow/tools/pip_package:build_pip_package”, and I got an error message:

ERROR: /tensorflow/tensorflow/BUILD:724:1: Linking of rule ‘//tensorflow:libtensorflow_framework.so.2.4.4’ failed (Exit 1)
/usr/bin/ld: bazel-out/k8-dbg/bin/tensorflow/stream_executor/cuda/libcublas_plugin.lo(cuda_blas.pic.o): relocation R_X86_64_PC32 against undefined symbol `_ZN15stream_executor3gpu12_GLOBAL__N_120CUDABlasLtMatmulPlan14kMaxBatchCountE’ can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
Target //tensorflow/tools/pip_package:build_pip_package failed to build.

If you see the commit date:

It was not available on the v2.4 tag.