Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Integrate TensorFlow with CMake projects effortlessly
| Date | Stars |
|---|---|
| 2026-07-24 | 335 |
| 2026-07-25 | 335 |
| 2026-07-28 | 335 |
| 2026-07-30 | 335 |
| 2026-08-06 | 335 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# tensorflow-cmake
Integrate TensorFlow with CMake projects effortlessly.
## TensorFlow
[TensorFlow](https://www.tensorflow.org/) is an amazing tool for machine learning and intelligence using computational graphs.
TensorFlow includes APIs for both Python and C++, although the C++ API is slightly less documented. However, the most standard
way to integrate C++ projects with TensorFlow is to build the project *inside* the TensorFlow repository, yielding a massive binary.
Additionally, [Bazel](http://www.bazel.io/) is the only certified way to build such projects. This document and the code in this
repository will allow one to integrate TensorFlow with CMake projects without producing a large binary.
Note: The instructions here correspond to an Ubuntu Linux environment; although some commands may differ for other operating systems and distributions, the general ideas are identical.
## Step 1: Install TensorFlow
Follow the [instructions](http://www.bazel.io/docs/install.html) for installing Bazel. Install dependencies and clone
TensorFlow from its git repository:
```bash
sudo apt-get install autoconf automake libtool curl make g++ unzip # Protobuf Dependencies
sudo apt-get install python-numpy swig python-dev python-wheel # TensorFlow Dependencies
git clone https://github.com/tensorflow/tensorflow # TensorFlow
```
Enter the cloned repository, and append the following to the `tensorflow/BUILD` file:
```bash
# Added build rule
cc_binary(
name = "libtensorflow_all.so",
linkshared = 1,
linkopts = ["-Wl,--version-script=tensorflow/tf_version_script.lds"], # Remove this line if you are using MacOS
deps = [
"//tensorflow/core:framework_internal",
"//tensorflow/core:tensorflow",
"//tensorflow/cc:cc_ops",
"//tensorflow/cc:client_session",
"//tensorflow/cc:scope",
"//tensorflow/c:c_api",
],
)
```
This specifies a new build rule, producing `libtensorflow_all.so`, that includes all the required dependencies for integration
with a C++ project. Build the shared library and copy it to `/usr/local/lib` as follows:
```bash
./configure # Note that this requires user input
bazel build tensorflow:libtensorflow_all.so
sudo cp bazel-bin/tensorflow/libtensorflow_all.so /usr/local/lib
```
Copy the source to `/usr/local/include/google` and remove unneeded items:
```bash
sudo mkdir -p /usr/local/include/google/tensorflow
sudo cp -r tensorflow /usr/local/include/google/tensorflow/
sudo find /usr/local/include/google/tensorflow/tensorflow -type f ! -name "*.h" -delete
```
Copy all generated files from bazel-genfiles:
```bash
sudo cp bazel-genfiles/tensorflow/core/framework/*.h /usr/local/include/google/tensorflow/tensorflow/core/framework
sudo cp bazel-genfiles/tensorflow/core/kernels/*.h /usr/local/include/google/tensorflow/tensorflow/core/kernels
sudo cp bazel-genfiles/tensorflow/core/lib/core/*.h /usr/local/include/google/tensorflow/tensorflow/core/lib/core
sudo cp bazel-genfiles/tensorflow/core/protobuf/*.h /usr/local/include/google/tensorflow/tensorflow/core/protobuf
sudo cp bazel-genfiles/tensorflow/core/util/*.h /usr/local/include/google/tensorflow/tensorflow/core/util
sudo cp bazel-genfiles/tensorflow/cc/ops/*.h /usr/local/include/google/tensorflow/tensorflow/cc/ops
```
Copy the third party directory:
```bash
sudo cp -r third_party /usr/local/include/google/tensorflow/
sudo rm -r /usr/local/include/google/tensorflow/third_party/py
# Note: newer versions of TensorFlow do not have the following directory
sudo rm -r /usr/local/include/google/tensorflow/third_party/avro
```
## Step 2: Install Eigen and Protobuf
The TensorFlow runtime library requires both [Protobuf](https://developers.google.com/protocol-buffers/) and [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page).
However, specific versions are required, and these may clash with currently installed versions of either software. Therefore, two options are
provided:
- Install the pExcerpt of 9,956 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:a0b837562796a22f, topic:tensorflow