Skip to content

Commit c4f3533

Browse files
update
1 parent 678133c commit c4f3533

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

compile_tensorflow_cpp.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Compile TensorFlow C++ from source code <!-- omit in toc -->
22

3-
Building TensorFlow C++ API is very tricky and can be a pain as there is not much information you can find about it even on TensorFlow's official documentation. Following you will find a step-by-step instruction showing how to build TensorFlow C++ v2 on Linux. It works well for my Ubuntu 20.04 running on AMD Ryzen processors.
3+
Building TensorFlow C++ API is very tricky and can be a pain as there is not much information you can find
4+
about it even on TensorFlow's official documentation. Following you will find a step-by-step instruction
5+
showing how to build TensorFlow C++ v2 on Linux. It works well for my Ubuntu 20.04 running on AMD Ryzen processors.
46

5-
On this page, I will walk you through the steps to install **TensorFlow C++ API version 2.7**.
7+
On this page, I will walk you through the steps to install **TensorFlow C++ API version 2.7** and **2.11**.
68

79
- [Dependencies](#dependencies)
810
- [Install package dependencies](#install-package-dependencies)
@@ -24,7 +26,8 @@ On this page, I will walk you through the steps to install **TensorFlow C++ API
2426
- Bazel*
2527
- Protobuf*
2628

27-
*a supported version depends on the version of TensorFlow. For TensorFlow v2.7, Python 3.9.9, GCC 10.3.0, Bazel 3.7.2, and Protobuf 3.9.2 work for me.
29+
*Supported version depends on the version of TensorFlow. For TensorFlow v2.7, I used Python 3.9.9, GCC 10.3.0,
30+
Bazel 3.7.2, and Protobuf 3.9.2, whereas for TensorFlow v2.11 I use Bazel 5.3.0.
2831

2932
A list of supported Python, compiler and Bazel can be found [here](https://www.tensorflow.org/install/source#tested_build_configurations).
3033

@@ -135,7 +138,12 @@ Preconfigured Bazel build configs to DISABLE default on features:
135138
Configuration finished
136139
```
137140

138-
Let's compile using bazel `build` rule:
141+
You can use the following command to check all available rules in a specific top directory:
142+
```bash
143+
bazel query ...
144+
```
145+
146+
Let's compile TensorFlow v2.7 using bazel `build` rule:
139147
```bash
140148
export CC=gcc
141149
export CXX=g++
@@ -148,10 +156,9 @@ bazel build --jobs=4 --local_ram_resources="HOST_RAM*.50" \
148156
//tensorflow:install_headers
149157
```
150158

151-
You can use the following command to check all available rules in a specific top directory:
152-
```bash
153-
bazel query ...
154-
```
159+
For v2.11 you can also use the above bazal build command. From v2.9 on, you can compile TensorFlow with the new
160+
ABI librar which is introduced in GCC 5 and newer version by setting `--cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1"`
161+
(see [the release log here](https://github.com/tensorflow/tensorflow/releases/tag/v2.9.0)).
155162

156163
Note:
157164

0 commit comments

Comments
 (0)