Trouble in getting tensorflow in RZG1M

Hi,

I have RZG1M starter kit and have to port tensorflow on the board. I am trying to cross compile tensor flow for this board and followed https://github.com/bazelbuild/bazel/wiki/Building-with-a-custom-toolchain for cross compiling but while issuing "bazel build <> <>" all the changes are getting deleted. it will be great if anyone can help to provide tensorflow wheel package for armv7l(unicode 2) or provide some inputs on cross compiling tensorflow for RZG1M starter kit. Since ResberryPi is ARM so tried to follow https://github.com/samjabrahams/tensorflow-on-raspberry-pi/blob/master/GUIDE.md but no luck...  

  • Hi,

    Are you already running a Linux BSP on the RZ/G1M SK board?
    I would suggest downloading a pre-built BSP from renesas.com and running that on the board. Here is the link -
    www.renesas.com/.../rzg1m.html

    The BSP to download is 'HMI and Multimedia Starter BSP ...'. It contains a native toolchain, so you should be able to use the build steps for Raspberry Pi (with some modifications) and build on the board.

    If you want to cross-compile you can also download a SDK from the same link as well. Cross compiling will be much faster but I am not sure how it would work for things like Bazel.

    One thing to note is that the RZ/G Linux BSP is Yocto based, not Debian, so there is no 'apt-get'. Some of the packages that they install with apt-get in the RPi instructions are already part of the BSP, other will need to be installed.
    I think it would be easier if I build those packages for you and send them so that you can install them on your BSP.

    Let me know how you would like to proceed and we'll go from there.

    Regards,
    Georgi
  • In reply to Georgi:

    Hi Georgi,

    Thank you for the prompt reply.

    >>>>Are you already running a Linux BSP on the RZ/G1M SK board?>>>>>>>>
    yes we are running Linux BSP on the RZ/G1M board.

    just to give more information:
    --->We are using starter Kit elinux.org/.../SK-RZG1M
    --->and running x11 image by following instruction elinux.org/.../Yocto
    ---->additionally we have created ipks for opencv and python-pip(using bitbake opencv and bitbake python-pip)
    ---->To get opencv and pip we have added setupup tools(downloaded from internet) and other dependencies.
    ----> requirement is to get the opencv and tensorflow. Since bazel creates the .whl package and uses pip to install thats why we installed pip.
    ----> Since we have planned to cross compile tensorflow on build server for the board and execute the wheel package on board but could not get the cross-compiled tensorflow wheel package for armv7l.

    As you mentioned in the solution that we have 2 ways now:
    1. Cross-compile using the sdk but success is not sure.
    2. build on the board: As you said that apt get is not available on the board so will not be able to get all the dependencies.

    we would like to go ahead with option 2 i.e. build on board.
    It will great if you can build those packages for us and send so that you can install them on your BSP

    Thank You
  • In reply to kalindee:

    Sorry for typo.
    we would like to go ahead with option 2 i.e. build on board.
    It will great if you can build those packages for us and send so that we can install on the board.
  • In reply to kalindee:

    Hi Kalindee,

    Following the steps for building Tensorflow on the RPi I managed to get the bazel build going. Everything compiles, but the build fails during the generation of the final zip file.
    So far I haven't found a fix for that. Here are my build steps, maybe you will have a better luck -

    1. Use bitbake and build 'zip', 'unzip' and 'wget', since the ones in the BSP are implemented by busybox and lack some options. Install the ipks on the board

    2. Install Java on the board. I downloaded JDK 1.8 from oracle - jdk-8u121-Linux-arm32-vfp-hflt.tar.gz
    2.1. Unzip the archive on the board, e.g. under /usr/java
    2.1. Setup the necessary environmental variables -
    $ export JAVA_HOME=/usr/java/jdk1.8.0_121
    $ export JAVA_ROOT=/usr/java/jdk1.8.0_121
    $ JAVA_BINDIR=$JAVA_HOME/bin
    $ export PATH=$JAVA_BINDIR:$PATH

    3. Follow the RPi steps for building bazel.

    The build takes about 30 minutes.

    Regards,
    Georgi
  • In reply to Georgi:

    Hi Georgi,

    Thank you for the inputs. :-)

    I have tried the same as you mentioned but bazel build could not succeed and stopped with the following msg:

    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    15 warnings
    .unzip -qn third_party/java/jarjar/jarjar-1.4.jar -d /tmp/bazel_ZNpUelcZ/classes
    unzip -qn third_party/java/jdk/langtools/javac-9-dev-r3297-1.jar -d /tmp/bazel_ZNpUelcZ/classes
    unzip: zip flags 1 and 8 are not supported
    root@skrzg1m:~/tf/bazel#

    did you come across this while building the bazel?

    do I need to cross compile latest unzip and deploy on the board?

    With Regards,
    Kalindee
  • In reply to kalindee:

    Hi Kalindee,

    Yes, you need to build and install unzip and zip (and also wget if you want to use it on the board). The default BSP has these commands implemented by busybox and apparently those implementations lack some options used by this build.

    Regards,
    Georgi
  • In reply to Georgi:

    Hi Georgi,

    Thank you for the solution. We could build the bazel successfully but execution shows the following error.

    Determinism test./home/root/tf/bazel/output/bazel --nomaster_bazelrc --bazelrc=/dev/null clean --expunge
    Extracting Bazel installation...
    .....................................................
    pure virtual method called
    terminate called without an active exception
    scripts/bootstrap/buildenv.sh: line 192: 11072 Aborted "${@}"

    root@skrzg1m:~/tf/bazel# bazel
    -sh: /usr/local/bin/bazel: cannot execute binary file: Exec format error
    root@skrzg1m:~/tf/bazel# cp output/bazel /usr/local/bin/bazel
    root@skrzg1m:~/tf/bazel# bazel
    pure virtual method called
    terminate called without an active exception
    Aborted
    root@skrzg1m:~/tf/bazel#

    Is the problem caused by wrong toolchains used for building bazel?
    Do you have any inputs on these issues?

    Regards,
    Kalindee
  • In reply to kalindee:

    Hi Kalindee,

    I don't think this is caused by the wrong toolchain but there might be some compiler options that cause or would prevent this. Unfortunately quick googling for 'pure virtual method called' didn't reveal any specific fix.
    Did you try to debug the application?

    I am wondering whether building on the board is the right approach or maybe cross compiling TensorFlow would be better.

    Regards,
    Georgi
  • In reply to Georgi:

    Hi Georgi,

    I have tried to debug but could not succeed to resolve this error.

    Regarding Cross-Compilation :I have tried to cross compile tensor flow using bazel but could not get the executable (.whl) file.

    Steps to Cross-compile:
    1.To Install Bazel
    $ sudo apt-get install openjdk-8-jdk
    $ echo "deb [arch=amd64] storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
    $ curl bazel.build/bazel-release.pub.gpg | sudo apt-key add -
    $ sudo apt-get update && sudo apt-get install bazel
    $ sudo apt-get upgrade bazel

    2.Clone the TensorFlow repository
    $ git clone github.com/.../tensorflow
    $ cd tensorflow
    $ git checkout r1.3

    3.Install python dependencies
    $ sudo apt-get install python-numpy python-dev python-pip python-wheel

    4.Configuration
    $ ./configure
    and follow the instructions provided in 'www.tensorflow.org/.../install_sources'

    5.For Cross compilation followed the steps mentioned in the bellow link
    github.com/.../Building-with-a-custom-toolchain

    Do:

    bazel build --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a //tensorflow/tools/pip_package:build_pip_package


    Error:

    /home/gopinathr/Documents/work/tensorflow/tools/arm_compiler/BUILD:58:1: in cc_toolchain rule //tools/arm_compiler:cc-compiler-armeabi-v7a: The package '@org_linaro_components_toolchain_gcc' is not valid
    ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted
  • In reply to Georgi:

    Hi Georgi,

    If possible,can you please provide the toolchain for cross compilation of tensorflow?

    Thanks in advance.

    With Regards,
    Kalindee
  • In reply to kalindee:

    Hi Kalindee,

    Sorry, I haven't had time to try cross-compiling tensorflow yet.

    You can download a cross toolchain from renesas.com -
    www.renesas.com/.../rzg1m.html

    This is for our Linux 3.10/Yocto 1.6 based BSP. You can download the BSP from the same page ('HMI and Multimedia Starter BSP..').
    If you want to build it yourself, the instructions are on elinux -
    elinux.org/.../Yocto

    Regards,
    Georgi
  • In reply to Georgi:

    Hi Georgi,

    I tried to cross-compile tensorflow(python lib) but could not succeed .
    I could compile tensorflow cpp library on RZ/G1M board(native compilation) using github.com/.../makefile.

    Now trying to compile tensorflow(python lib) on RZ/G1M.

    Thank You.

    With Regards,
    Kalindee