@@ -4,6 +4,19 @@ Building TensorFlow C++ API is very tricky and can be a pain as there is not muc
4
4
5
5
On this page, I will walk you through the steps to install ** TensorFlow C++ API version 2.7** .
6
6
7
+ - [ Compile TensorFlow C++ from source code] ( #compile-tensorflow-c-from-source-code )
8
+ - [ Dependencies] ( #dependencies )
9
+ - [ Install package dependencies] ( #install-package-dependencies )
10
+ - [ 1. Environment setup] ( #1-environment-setup )
11
+ - [ 2. Install Bazel] ( #2-install-bazel )
12
+ - [ 3. Install Protobuf] ( #3-install-protobuf )
13
+ - [ Compile TensorFlow C++ and install libraries] ( #compile-tensorflow-c-and-install-libraries )
14
+ - [ 1. Compile TensorFlow C++ shared library (with optimization)] ( #1-compile-tensorflow-c-shared-library-with-optimization )
15
+ - [ 2. Copy required files into a single path for C++ linkage] ( #2-copy-required-files-into-a-single-path-for-c-linkage )
16
+ - [ 3. Compiling the op library and example code] ( #3-compiling-the-op-library-and-example-code )
17
+ - [ Optional: Compile TensorFlow via pip (wheel) builder] ( #optional-compile-tensorflow-via-pip-wheel-builder )
18
+ - [ References] ( #references )
19
+
7
20
## Dependencies
8
21
9
22
- Conda
@@ -58,7 +71,17 @@ chmod +x bazel-3.7.2-installer-linux-x86_64.sh
58
71
59
72
### 3. Install Protobuf
60
73
61
- I suggest installing protobuf after building TensorFlow (see below) so that we are able to check that which version of protobuf we should use.
74
+ 1 . Check the version of protobuf that is supported by TensorFlow in the file ` tensorflow/workspace2.bzl ` ,
75
+ e.g., TF 2.7.0 supports Protobuf 3.9.2
76
+ 2 . Download protobuf source code from its GitHub release https://github.com/protocolbuffers/protobuf/tags
77
+ - E.g. v3.9.2 https://github.com/protocolbuffers/protobuf/releases/tag/v3.9.2
78
+ 3 . Compile and link
79
+ ``` bash
80
+ ./configure --prefix=/home/rangsiman/protobuf-3.9.2/ CXXFLAGS=" -D_GLIBCXX_USE_CXX11_ABI=0"
81
+ make
82
+ make check
83
+ make install
84
+ ```
62
85
63
86
---
64
87
@@ -165,24 +188,7 @@ pip install /tmp/tensorflow_pkg/tensorflow-2.3.0-cp38-cp38-linux_x86_64.whl
165
188
python -c " import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
166
189
```
167
190
168
- ### 2. Install protobuf
169
-
170
- 1 . Check the version of protobuf that is supported by TensorFlow
171
- ``` bash
172
- bazel-bin/external/com_google_protobuf/protoc --version
173
- libprotoc 3.9.2
174
- ```
175
- 2 . Download protobuf source code from its GitHub release https://github.com/protocolbuffers/protobuf/tags
176
- - E.g. v3.9.2 https://github.com/protocolbuffers/protobuf/releases/tag/v3.9.2
177
- 4 . Compile and link
178
- ``` bash
179
- ./configure --prefix=/home/rangsiman/protobuf-3.9.2/
180
- make
181
- make check
182
- make install
183
- ```
184
-
185
- ### 3. Copy required files into a single path for C++ linkage
191
+ ### 2. Copy required files into a single path for C++ linkage
186
192
187
193
``` bash
188
194
sudo mkdir /usr/local/tensorflow
@@ -193,7 +199,7 @@ sudo cp -r bazel-bin/tensorflow/*.so* /usr/local/tensorflow/lib
193
199
sudo cp -r /home/rangsiman/protobuf-3.9.2/lib/* .so* /usr/local/tensorflow/lib
194
200
```
195
201
196
- ### 4 . Compiling the op library and example code
202
+ ### 3 . Compiling the op library and example code
197
203
198
204
** Example-1** : Zero out
199
205
0 commit comments