Skip to content

Commit ea6c12e

Browse files
Update compile_tensorflow_cpp.md
1 parent 5919ede commit ea6c12e

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

compile_tensorflow_cpp.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ bazel build --jobs=4 --local_ram_resources="HOST_RAM*.50" \
123123
//tensorflow:libtensorflow.so \
124124
//tensorflow:libtensorflow_cc.so \
125125
//tensorflow:libtensorflow_framework.so \
126-
//tensorflow:install_headers \
127-
//tensorflow/tools/pip_package:build_pip_package
126+
//tensorflow:install_headers
128127
```
129128

130129
You can use the following command to check all available rules in a specific top directory:
@@ -143,12 +142,29 @@ Note:
143142
7. Flags for Intel: `--copt=-mavx --copt=-mavx2`.
144143
8. Rebuild with `--config=monolithic` if you want to compile all TensorFlow C++ code into a single shared object.
145144

146-
**optional**
145+
**Optional 1:** Test
147146
```bash
148147
bazel test --jobs=4 --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" -c opt \
149148
//tensorflow/tools/lib_package:libtensorflow_test
150149
```
151150

151+
**Optional 2:**
152+
Additionally, you can also build TensorFlow wheel file (.whl) which can then be used to install TensorFlow by pip:
153+
154+
```bash
155+
# Build process
156+
bazel build --config=opt -c opt //tensorflow/tools/pip_package:build_pip_package
157+
158+
# Create a wheel file
159+
./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
160+
161+
# Install TensorFlow using the wheel file
162+
pip install /tmp/tensorflow_pkg/tensorflow-2.3.0-cp38-cp38-linux_x86_64.whl
163+
164+
# Try importing TensorFlow and test it
165+
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
166+
```
167+
152168
### 2. Install protobuf
153169

154170
1. Check the version of protobuf that is supported by TensorFlow

0 commit comments

Comments
 (0)