jgoenetxea
4/2/2019 - 1:28 PM

How to install properly tensorflow_cc

#! /bin/bash
 
# Requires bazel 0.19.2
# wget https://github.com/bazelbuild/bazel/releases/download/0.19.2/bazel_0.19.2-linux-x86_64.deb
# dpkg -i bazel_0.19.2-linux-x86_64.deb
# rm bazel_0.19.2-linux-x86_64.deb

git clone https://github.com/FloopCZ/tensorflow_cc.git
cd tensorflow_cc && git checkout v1.12.0
# Edit tensorflow install settings
sed -i "s|master\ \-\-\ tensorflow\/tf\_version\_script\.lds|v1\.13\.0\-rc0|g" tensorflow_cc/tensorflow_cc/cmake/TensorflowBa    se.cmake
sed -i "s|ivybridge|native|g" tensorflow_cc/tensorflow_cc/cmake/build_tensorflow.sh.in
# sed -i "s|TF\_NEED\_TENSORRT\:\-0|TF\_NEED\_TENSORRT\:\-1|g" ./tensorflow_cc/tensorflow_cc/cmake/build_tensorflow.sh.in
# sed -i '/g++-7/d' ./tensorflow_cc/tensorflow_cc/cmake/TensorflowShared.cmake

mkdir -p ./tensorflow_cc/tensorflow_cc/build
cd tensorflow_cc/tensorflow_cc/build && cmake -DTENSORFLOW_STATIC=OFF -DTENSORFLOW_SHARED=ON .. && \
   make -j8 && sudo make install && rm -rf ~/.cache && cd .. && rm -rf build
#! /bin/bash
 
# Requires bazel 0.19.2
# wget https://github.com/bazelbuild/bazel/releases/download/0.19.2/bazel_0.19.2-linux-x86_64.deb
# dpkg -i bazel_0.19.2-linux-x86_64.deb
# rm bazel_0.19.2-linux-x86_64.deb

git clone https://github.com/FloopCZ/tensorflow_cc.git
cd tensorflow_cc && git checkout v1.12.0
sed -i "s|master\ \-\-\ tensorflow\/tf\_version\_script\.lds|v1\.13\.0\-rc0|g" tensorflow_cc/cmake/TensorflowBase.cmake
sed -i "s|ivybridge|native|g" tensorflow_cc/cmake/build_tensorflow.sh.in
sed -i "s|TF\_NEED\_TENSORRT\:\-0|TF\_NEED\_TENSORRT\:\-1|g" tensorflow_cc/cmake/build_tensorflow.sh.in
sed -i '/g++-7/d' tensorflow_cc/cmake/TensorflowShared.cmake
sed -i "/set\ \-e/a sed\ \-i\ '\/\\\"\\\/\\\/tensorflow\\\/cc\\\:scope\\\"\\\,\/a\ \\\"\\\/\\\/tensorflow\\\/contrib\\\/tensorrt\\\:trt\\\_conversion\\\"\\\,'\ \/tensorflow_cc\/tensorflow_cc\/build\/tensorflow\/tensorflow\/BUILD" tensorflow_cc/cmake/build_tensorflow.sh.in
sed -i "/set\ \-e/a sed\ \-i\ '\/\\\"\\\/\\\/tensorflow\\\/cc\\\:scope\\\"\\\,\/a\ \\\"\\\/\\\/tensorflow\\\/contrib\\\/tensorrt\\\:trt\\\_engine\\\_op\\\_kernel\\\"\\\,'\ \/tensorflow_cc\/tensorflow_cc\/build\/tensorflow\/tensorflow\/BUILD" tensorflow_cc/cmake/build_tensorflow.sh.in
sed -i "/set\ \-e/a sed\ \-i\ '\/\\\"kernels\\\/trt\\\_engine\\\_op\\\.cc\\\"\\\,\/a\ \\\"ops\\\/trt\\\_engine\\\_op\\\.cc\\\"\\\,'\ \/tensorflow_cc\/tensorflow_cc\/build\/tensorflow\/tensorflow\/contrib\/tensorrt\/BUILD" tensorflow_cc/cmake/build_tensorflow.sh.in
sed -i "/set\ \-e/a sed\ \-i\ '\/\\\"\\\:trt\\\_resources\\\"\\\,\/a\ \\\"\\\:trt\\\_shape\\\_function\\\"\\\,'\ \/tensorflow_cc\/tensorflow_cc\/build\/tensorflow\/tensorflow\/contrib\/tensorrt\/BUILD" tensorflow_cc/cmake/build_tensorflow.sh.in

mkdir -p tensorflow_cc/build
cd tensorflow_cc/build
cmake -DTENSORFLOW_STATIC=OFF -DTENSORFLOW_SHARED=ON ..

make -j8 && make install && rm -rf ~/.cache && cd .. && rm -rf build