Get the source from github
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow |
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
Install the prerequirement
sudo apt install python3-dev python3-pip
pip install -U --user pip six 'numpy<1.19.0' wheel setuptools mock 'future>=0.17.1' 'gast==0.3.3' typing_extensions
pip install -U --user keras_applications --no-deps
pip install -U --user keras_preprocessing --no-deps |
sudo apt install python3-dev python3-pip
pip install -U --user pip six 'numpy<1.19.0' wheel setuptools mock 'future>=0.17.1' 'gast==0.3.3' typing_extensions
pip install -U --user keras_applications --no-deps
pip install -U --user keras_preprocessing --no-deps
Configure the tensorflow
Install the build tool: Bazel
sudo apt install curl gnupg
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
sudo apt update && sudo apt install bazel |
sudo apt install curl gnupg
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
sudo apt update && sudo apt install bazel
编译和Debug设置
1 Build Tensorflow的debug版本,即可以用GDB Debug的版本:
Build的时候加上copt “-g”:
通过gdb conv_ops_3d.pic.o验证,只要不出现No symbols则说明debug信息有。
bazel build --config=opt --copt -g //tensorflow/tools/lib_package:libtensorflow --verbose_failures
#You can also use --per_file_copt to allow only some library with debug info.
bazel build --config=opt --per_file_copt=.*tensorflow.*@-g //tensorflow/tools/lib_package:libtensorflow --verbose_failures
[root@localhost conv_ops]# gdb conv_ops_3d.pic.o
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/.cache/bazel/_bazel_root/e88dc1dcc3c90dfdeee7304faf39c313/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/core/kernels/_objs/conv_ops/conv_ops_3d.pic.o...done.
(gdb)
#Other libraries may need for debuging.
bazel build --config=opt --copt -g //tensorflow/cc:cc_ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/c:c_test_util --verbose_failures
bazel build --config=opt --copt -g //tensorflow/c:c_api --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:cc_ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:const_op --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:array_ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:match_ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:math_ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:scope --verbose_failures
bazel build --config=opt --copt -g //tensorflow/core:test --verbose_failures
bazel build --config=opt --copt -g //tensorflow/core:testlib --verbose_failures
bazel build --config=opt --copt -g //tensorflow/core/kernels:ops_testutil --verbose_failures |
bazel build --config=opt --copt -g //tensorflow/tools/lib_package:libtensorflow --verbose_failures
#You can also use --per_file_copt to allow only some library with debug info.
bazel build --config=opt --per_file_copt=.*tensorflow.*@-g //tensorflow/tools/lib_package:libtensorflow --verbose_failures
[root@localhost conv_ops]# gdb conv_ops_3d.pic.o
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/.cache/bazel/_bazel_root/e88dc1dcc3c90dfdeee7304faf39c313/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/core/kernels/_objs/conv_ops/conv_ops_3d.pic.o...done.
(gdb)
#Other libraries may need for debuging.
bazel build --config=opt --copt -g //tensorflow/cc:cc_ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/c:c_test_util --verbose_failures
bazel build --config=opt --copt -g //tensorflow/c:c_api --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:cc_ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:const_op --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:array_ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:match_ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:math_ops --verbose_failures
bazel build --config=opt --copt -g //tensorflow/cc:scope --verbose_failures
bazel build --config=opt --copt -g //tensorflow/core:test --verbose_failures
bazel build --config=opt --copt -g //tensorflow/core:testlib --verbose_failures
bazel build --config=opt --copt -g //tensorflow/core/kernels:ops_testutil --verbose_failures
继续阅读“Tensorflow Debug with CDT”本作品采用知识共享署名 4.0 国际许可协议进行许可。