Last active
June 25, 2022 01:05
-
-
Save seunboy1/3fca9a160ea722960f6d1aa381954918 to your computer and use it in GitHub Desktop.
How to install tensorflow c++ on ubuntu 18.04 with cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This was taken from this repo https://github.com/FloopCZ/tensorflow_cc | |
#Download and install requirement | |
sudo apt-get install cmake curl g++-7 git python3-dev python3-numpy sudo wget | |
# Install Bazel | |
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - | |
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list | |
sudo apt-get update && sudo apt-get install bazel | |
# if it fails install bazel version 2.0.0 | |
sudo apt update && sudo apt install bazel 2.0.0 | |
sudo apt update && sudo apt full-upgrade | |
OR | |
sudo apt install g++ unzip zip | |
#then download the Bazel binary installer named bazel-2.0.0-installer-linux-x86_64.sh from https://github.com/bazelbuild/bazel/releases | |
chmod +x bazel-<version>-installer-linux-x86_64.sh | |
./bazel-<version>-installer-linux-x86_64.sh --user | |
export PATH="$PATH:$HOME/bin" | |
# clone the repo | |
git clone https://github.com/FloopCZ/tensorflow_cc.git | |
cd tensorflow_cc | |
# Build and install the library | |
cd tensorflow_cc | |
mkdir build && cd build | |
cmake .. | |
make | |
sudo make install | |
#Add the following into your Cmake file | |
# CMakeLists.txt | |
find_package(TensorflowCC REQUIRED) | |
add_executable(example example.cpp) | |
# Link the Tensorflow library. | |
target_link_libraries(example TensorflowCC::TensorflowCC) | |
### Step Six | |
Go to your current working directory, build and run your program | |
mkdir build && cd build | |
cmake .. && --build . | |
./example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment