facebookarchive / caffe2

Caffe2 is a lightweight, modular, and scalable deep learning framework.
https://caffe2.ai
Apache License 2.0
8.42k stars 1.95k forks source link

A shell script to build Tizen target #847

Closed leemgs closed 7 years ago

leemgs commented 7 years ago

I can find appropriate build scripts for Windows, iOS, Android, Raspbian, and Tegra at the below webpage.

Where can I find a build script in case that I want to build the Tizen target (https://www.tizen.org)?

leemgs commented 7 years ago

Here is a case study to to build Caffe2 with Tizen 4.0.m1-based your own rootfs for yourself for ARMv7 little-endian architecture. We assume that you are planning to execute a Caffe2-based intelligent application on a Tizen 4.0/M1 based RPi3 reference board. Even though you do not have a real embedded device such as Raspberry Pi3, don't worry about it. You could build and run Caffe2 on Ubuntu 16.04 LTS X64 thanks to QEMU (Virtualization Type 2).

u16.04$> firefox http://download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-base_20170520.1/repos/arm/packages/armv7l/

u16.04$> firefox http://download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-unified_20170529.1/repos/standard/packages/armv7l/


* 2nd step: Make your own Tizen 4.0 rootfs (for ARMV7L architecture)

u16.04$> mkdir -p /work/tizen/snapshot-rpi3-armv7l u16.04$> cd /work/tizen/snapshot-rpi3-armv7l u16.04$> sudo cp /usr/bin/qemu-arm-static ./mytizenrootfs/usr/bin/ u16.04$> sudo chroot ./mytizenrootfs/ qemu-arm-static /usr/bin/bash


* 3rd step: Add repo files (both base and unified) for zypper-based package management
For checking the latest version of zypper, visit https://git.tizen.org/cgit/platform/upstream/zypper/

tizen4.0# cd etc/zypp/repos.d tizen4.0# mv *.repo /opt tizen4.0# vi ./tizen-unified-standard-release-base.repo [tizen-unified-standard-release-base] name=tizen-unified-standard-release-base enabled=1 autorefresh=0 baseurl=http://download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-base_20170520.1/repos/arm/packages/?ssl_verify=no type=rpm-md gpgcheck=0

[tizen-unified-standard-release-debug-base] name=tizen-unified-standard-release-debug-base enabled=1 autorefresh=0 baseurl=http://download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-base_20170520.1/repos/arm/packages/?ssl_verify=no type=rpm-md gpgcheck=0

tizen4.0# tizen4.0# tizen4.0# vi ./tizen-unified-standard-release-unified.repo [tizen-unified-standard-release-unified] name=tizen-unified-standard-release-unified enabled=1 autorefresh=0 baseurl=http://download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-unified_20170529.1/repos/standard/packages/?ssl_verify=no type=rpm-md gpgcheck=0

[tizen-unified-standard-release-debug-unified] name=tizen-unified-standard-release-debug-unified enabled=1 autorefresh=0 baseurl=http://download.tizen.org/releases/milestone/tizen/4.0.m1/tizen-unified_20170529.1/repos/standard/debug/?ssl_verify=no type=rpm-md gpgcheck=0


* 4th step: Install additional package to build Caffe2

tizen4.0# zypper update tizen4.0# zypper install make strace cmake gcc binutils glibc cpp protobuf-devel git libstdc++*


* 5th step: Build Caffe2 (w/ ver. 0.7.0)
 * Note that you have to wait for a long time (in my case, +40 minutes) due to QEMU's limitation such as 1) No H/W virtualization for CPU and 2) software I/O emulation.

tizen4.0# cd /opt/caffe2 tizen4.0# git checkout v0.7.0 tizen4.0# mkdir build && cd build tizen4.0# cmake -DUSE_GFLAGS=OFF -DUSE_GLOG=OFF \ -DUSE_NNPACK=OFF -DRUN_HAVE_STD_REGEX=0 \ -DRUN_HAVE_POSIX_REGEX=0 -DHAVE_GNU_POSIX_REGEX=0 \ -DUSE_MPI=OFF -DUSE_OPENMP=OFF -DUSE_ROCKSDB=OFF \ -DUSE_LEVELDB=OFF -DUSE_LMDB=OFF -DBUILD_PYTHON=OFF \ -DUSE_GLOO=OFF -DUSE_OPENCV=OFF \ -DCAFFE2_CPU_FLAGS="-mfpu=neon -mfloat-abi=soft" \ ..


* Final step: Check a generated *.so files. Then enjoy Caffe2.!!!!

tizen4.0# find . -name *.so ./third_party/benchmark/src/libbenchmark.so ./third_party/googletest/googlemock/gtest/libgtest.so ./third_party/googletest/googlemock/gtest/libgtest_main.so ./third_party/googletest/googlemock/libgmock_main.so ./third_party/googletest/googlemock/libgmock.so ./caffe2/libCaffe2_CPU.so tizen4.0# tizen4.0# ldd ./build/caffe2/libCaffe2_CPU.so /usr/lib/libsys-assert.so (0xf6204000) libprotobuf.so.9 => /lib/libprotobuf.so.9 (0xf612b000) libpthread.so.0 => /lib/libpthread.so.0 (0xf6102000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xf60da000) libstdc++.so.6 => /lib/libstdc++.so.6 (0xf5fd1000) libm.so.6 => /lib/libm.so.6 (0xf5f4e000) libc.so.6 => /lib/libc.so.6 (0xf5e14000) /lib/ld-linux.so.3 (0xf6fcf000) libunwind.so.8 => /lib/libunwind.so.8 (0xf5dd7000) libdl.so.2 => /lib/libdl.so.2 (0xf5dc3000) tizen4.0# tizen4.0# tizen4.0# ls -al ./caffe2/libCaffe2_CPU.so -rwxr-xr-x 1 leemgs leemgs 7,524,240 Jul 7 19:34 ./caffe2/libCaffe2_CPU.so tizen4.0# tizen4.0# tizen4.0# file ./caffe2/libCaffe2_CPU.so ./caffe2/libCaffe2_CPU.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=2f5b9b2e400e8e97ad9d400dd677ddde9d20ebe7, not stripped tizen4.0# bash-3.2# size ./caffe2/libCaffe2_CPU.so text data bss dec hex filename 5832875 56696 19832 5909403 5a2b9b ./caffe2/libCaffe2_CPU.so bash-3.2# size --format=sysv ./caffe2/libCaffe2_CPU.so ./caffe2/libCaffe2_CPU.so : section size addr .note.gnu.build-id 36 244 .hash 73860 280 .dynsym 164064 74140 .dynstr 788412 238204 .gnu.version 20508 1026616 .gnu.version_r 432 1047124 .rel.dyn 82632 1047556 .rel.plt 22616 1130188 .init 12 1152804 .plt 33944 1152816 .text 4114076 1186760 .fini 8 5300836 .rodata 243880 5300848 .ARM.extab 247783 5544728 .ARM.exidx 40608 5792512 .eh_frame 4 5833120 .init_array 604 5898660 .fini_array 4 5899264 .jcr 4 5899268 .data.rel.ro 32984 5899272 .dynamic 280 5932256 .got 21616 5932536 .data 1204 5954152 .bss 19832 5955356 .comment 53 0 .ARM.attributes 49 0 .debug_aranges 88 0 .debug_info 198 0 .debug_abbrev 36 0 .debug_line 192 0 .debug_ranges 72 0 Total 5910091 tizen4.0# tizen4.0#