|
2 | 2 |
|
3 | 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.
|
4 | 4 |
|
5 |
| -In this page I will walk you through the steps to install **TensorFlow C++ API version 2.7**. |
| 5 | +On this page, I will walk you through the steps to install **TensorFlow C++ API version 2.7**. |
6 | 6 |
|
7 | 7 | ## Dependencies
|
8 | 8 |
|
9 | 9 | - Conda
|
10 |
| -- Python |
| 10 | +- Python + NumPy |
11 | 11 | - GCC 5 or higher
|
12 | 12 | - Bazel*
|
13 | 13 | - Protobuf*
|
14 | 14 |
|
15 | 15 | *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.
|
16 | 16 |
|
17 |
| -A list of supported Python, compiler, and Bazel can be found [here](https://www.tensorflow.org/install/source#tested_build_configurations). |
| 17 | +A list of supported Python, compiler and Bazel can be found [here](https://www.tensorflow.org/install/source#tested_build_configurations). |
18 | 18 |
|
19 | 19 | ---
|
20 | 20 |
|
21 | 21 | ## Install package dependencies
|
22 | 22 |
|
23 |
| -### 1. Environment setup & install Python |
| 23 | +### 1. Environment setup |
24 | 24 | ```bash
|
25 | 25 | conda create -n tfcc
|
26 | 26 | conda activate tfcc # or `source activate tfcc`
|
27 |
| -conda install python==3.9.9 |
28 | 27 | conda update --all -y
|
| 28 | +conda install python==3.9.9 |
| 29 | +conda install numpy |
29 | 30 | ```
|
30 | 31 |
|
31 |
| -### 2. Install bazel |
| 32 | +### 2. Install Bazel |
32 | 33 |
|
33 | 34 | Check a supported version at `tensorflow/.bazelversion`.
|
34 | 35 |
|
@@ -71,12 +72,19 @@ cd tensorflow
|
71 | 72 | git checkout r2.7
|
72 | 73 | ```
|
73 | 74 |
|
| 75 | +Configure the build: |
| 76 | +```bash |
| 77 | +./configure |
| 78 | +# I leave all answers empty, just Enter |
| 79 | +``` |
| 80 | + |
74 | 81 | Let's compile using bazel `build` rule:
|
75 | 82 | ```bash
|
76 | 83 | export CC=gcc
|
77 | 84 | export CXX=g++
|
78 | 85 | bazel build --jobs=4 --local_ram_resources="HOST_RAM*.50" \
|
79 | 86 | --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" -c opt \
|
| 87 | + --config=noaws --config=nogcp --config=hdfs --config=nccl \ |
80 | 88 | //tensorflow:libtensorflow.so \
|
81 | 89 | //tensorflow:libtensorflow_cc.so \
|
82 | 90 | //tensorflow:libtensorflow_framework.so \
|
|
0 commit comments