Skip to content

Instantly share code, notes, and snippets.

@lissyx
Last active January 6, 2017 14:13
Show Gist options
  • Save lissyx/28c1a0092d9a1ea73d786381682a91be to your computer and use it in GitHub Desktop.
Save lissyx/28c1a0092d9a1ea73d786381682a91be to your computer and use it in GitHub Desktop.
cross build libtensorflow-core rpi3 notes
cross-build protobuf:
- git clone https://github.com/raspberrypi/tools
- first build for linux host system, we need matching protoc
- mkdir /home/alex/codaz/Mozilla/DeepSpeech/tensorflow/protobuf
- CC=gcc-4.8 CXX=g++-4.8 ./configure --prefix=$HOME/codaz/Mozilla/DeepSpeech/tensorflow/protobuf/
- CC=gcc-4.8 CXX=g++-4.8 make -j8 && CC=gcc-4.8 CXX=g++-4.8 make install
- then cross-build for rpi3
- CC=/home/alex/codaz/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc CXX=/home/alex/codaz/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ ./configure --host=arm-linux-gnueabihf --with-sysroot=/home/alex/codaz/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/ --with-protoc=$HOME/codaz/Mozilla/DeepSpeech/tensorflow/protobuf/bin/protoc --prefix=$HOME/codaz/Mozilla/DeepSpeech/tensorflow/rpi3/
- make -j8 && make -j8 install
cross-build zlib:
- download & extract http://zlib.net/zlib-1.2.8.tar.gzake
- CC=/home/alex/codaz/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc ./configure --prefix=$HOME/codaz/Mozilla/DeepSpeech/tensorflow/rpi3/
- make -j8 && make install
cross-build libtensorflow-core:
- LC_ALL=C LD_LIBRARY_PATH=/home/alex/codaz/Mozilla/DeepSpeech/tensorflow/protobuf/lib:$LD_LIBRARY_PATH make -f tensorflow/contrib/makefile/Makefile HOST_OS=PI TARGET=PI HOST_CXX=gcc-4.8 HOST_CXXFLAGS="--std=c++11 -I/home/alex/codaz/Mozilla/DeepSpeech/tensorflow/protobuf/include -L/home/alex/codaz/Mozilla/DeepSpeech/tensorflow/protobuf/lib" CXX=/home/alex/codaz/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ PROTOC=/home/alex/codaz/Mozilla/DeepSpeech/tensorflow/protobuf/bin/protoc OPTFLAGS="-Os -funsafe-math-optimizations -ftree-vectorize --sysroot=/home/alex/codaz/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/libc/ -I/home/alex/codaz/Mozilla/DeepSpeech/tensorflow/rpi3/include/ -L/home/alex/codaz/Mozilla/DeepSpeech/tensorflow/rpi3/lib/" -j8
pi@raspberrypi:~ $ PATH=$HOME/.local/bin/:$PATH LD_LIBRARY_PATH=$HOME/.local/lib/:$LD_LIBRARY_PATH ldd ~/.local/bin/benchmark
linux-vdso.so.1 (0x7eea2000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f0f000)
libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x76e2d000)
libprotobuf.so.11 => /home/pi/.local/lib/libprotobuf.so.11 (0x76c30000)
libz.so.1 => /home/pi/.local/lib/libz.so.1 (0x76c11000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76bfe000)
libpthread.so.0 => /lib/arm-linux-gueabihf/libpthread.so.0 (0x76bd6000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76b5b000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x76b2e000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x769ed000)
/lib/ld-linux-armhf.so.3 (0x54b85000)
***
Cleanup after you played with Makefile: https://github.com/tensorflow/tensorflow/issues/5310#issuecomment-257415437
***
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment