Build Tensorflow from Source

TimoK93
TimoK93 New Member Posts: 27 ✭✭

Hi folks,

because i never found a thread containing discussions about compiling tensorflow from source on the Up Board, i open this thread.

Because i got problems by running some keras (backend tensorflow) scripts that work well on other machines, i guess there could be some difficults and so i will report my experiences using tensorflow.

First of all my experience till now:
I installed tensorflow 1.8 with Python 2.7 and 3.5 -> Keras scripts crashed after some seconds because of SIGFAULTS. I downgraded to 1.7 ... 1.6 ... and with 1.5 i got an version that is not crashing.

So now i try to build it manually from source using this guide https://www.tensorflow.org/install/source.

I will report results and would be happy for experiences from others!

Greetings,
Timo Kaiser

Tagged:

Comments

  • eduncan911
    eduncan911 Administrator, Moderator Posts: 157 admin

    Thanks @TimoK93 and yes let us know. I saw your other thread and found this post from it. I'm assuming this will use the integratesd Intel GPU?

    I will be taking a different approach and using the Intel OpenVINO Toolkit as my SDK for TensorFlow when I get my UP AI Core add-on board to try.

    Eric Duncan - UP Evangelist - My thoughts are of my own free will

    Answered? Please remember to mark the posted answered to highlight it for future visitors!

  • TimoK93
    TimoK93 New Member Posts: 27 ✭✭
    edited October 2018

    After some trials i installed tensorflow from source!

    I installed latest version (1.10) and used the defaults EXCEPT

    • no Google Support
    • no Hadoop Support
    • no Amazon Support
    • no Kafka Support
    • using the --option=mkl flag

    The first times I used a wrong bazel version (automatically installed the latest version). This caused some compiling errors. The building process lasts about ~3 hours.

    I'm assuming this will use the integratesd Intel GPU?

    I hoped it will, but i think it did not... While starting a tensorflow/keras script, it doesn't show some special "GPU output" you would see with NVIDIA GPUs. The first "test" shows, that the board is quite slowly... Next days i will present a benchmark with GPUs and CPUs and the UP-Board processing the same net.

    I will be taking a different approach and using the Intel OpenVINO Toolkit

    Can you report a little guide?

    Greetings
    Timo

  • eduncan911
    eduncan911 Administrator, Moderator Posts: 157 admin

    @TimoK93 said:

    I will be taking a different approach and using the Intel OpenVINO Toolkit

    Can you report a little guide?

    https://software.intel.com/en-us/openvino-toolkit/documentation/get-started

    I think those have some good getting started guides.

    Reading the specs of OpenVINO to use Intel's GPU graphics, it looks like you need the UP Squared or the up coming UP Core Plus because of their GPU:

    https://software.intel.com/en-us/openvino-toolkit/choose-download/free-download-linux

    I didn't see the GPUs of the UP Board on that initial list. But it could still work. I don't have a spare UP Board with Linux to try at the moment.

    It should still work without GPU accelleration on the UP Board. It does say that the Intel graphics/GPU are only required if you use GPU accelleration.

    I'm still new to these myself. Waiting on my hardware to play with some of it.

    Eric Duncan - UP Evangelist - My thoughts are of my own free will

    Answered? Please remember to mark the posted answered to highlight it for future visitors!

  • TimoK93
    TimoK93 New Member Posts: 27 ✭✭

    I tried installing OpenVINO and installation worked well except one Problem:
    The installer installs tensorflow (latest version) by using pip. This was the root problem, so now im trying to rebuilt and install tensorflow from source.

    I will report results!

  • TimoK93
    TimoK93 New Member Posts: 27 ✭✭

    I installed from source.

    Tensorflow is working but it seems that its working very slow... I do not notice that its working faster with OpenVINO installed. Do you know a possibility to investigate that Tensorflow is using the GPU?

  • eduncan911
    eduncan911 Administrator, Moderator Posts: 157 admin
    edited October 2018

    I am new to this as well. My UP^2 has Windows at the moment for some other work I am doing. So I haven't had time to investigate.

    Are you sure TensorFlow is using OpenVINO? From the online examples I saw, it would seem you need to modify the C++ complication settings to include the -d GPU parameters (can't recall the exaxt params at the moment, I'm on mobile).

    I ordered the AI Vision kit, but they are on back order due to Intel CPU mass shortage.

    Eric Duncan - UP Evangelist - My thoughts are of my own free will

    Answered? Please remember to mark the posted answered to highlight it for future visitors!

  • eduncan911
    eduncan911 Administrator, Moderator Posts: 157 admin

    @TimoK93 Did you follow the directions for enabling Graphics support for OpenVINO? It was at the very bottom of the installation guide:

    https://software.intel.com/en-us/articles/OpenVINO-Install-Linux#GPU-steps

    Eric Duncan - UP Evangelist - My thoughts are of my own free will

    Answered? Please remember to mark the posted answered to highlight it for future visitors!

  • TimoK93
    TimoK93 New Member Posts: 27 ✭✭

    @eduncan911 said:
    @TimoK93 Did you follow the directions for enabling Graphics support for OpenVINO? It was at the very bottom of the installation guide:

    https://software.intel.com/en-us/articles/OpenVINO-Install-Linux#GPU-steps

    Yes i did, except this step:

    7. (Optional) Install header files to allow compiling a new code. You can find the header files at https://github.com/KhronosGroup/OpenCL-Headers.git.

    I just realized, that i misapprehended the OpenVINO Tensorflow support... I thought that OpenVINO Tensorflow works like tensorflow-gpu. Thats my mistake: I did not convert the tensorflow-net to an inference machine. I just red this https://software.intel.com/en-us/articles/OpenVINO-Using-TensorFlow

    I will try to convert the model to the inference machine using the description above.

    One NOTE: I ordered the AI core so i can report my results with UP-Squared and UP-Squared with AI-Core.

  • TimoK93
    TimoK93 New Member Posts: 27 ✭✭

    Hey,
    here an intermediate result:

    I finished installing OpenVINO and converted a short model to the inference machine. Converting my favorite CNN is aborting with this Error: "Graph contains a cycle. Can not proceed"

    Going forward to solve the issue...

  • eduncan911
    eduncan911 Administrator, Moderator Posts: 157 admin

    @TimoK93 said:
    Hey,
    here an intermediate result:

    I finished installing OpenVINO and converted a short model to the inference machine. Converting my favorite CNN is aborting with this Error: "Graph contains a cycle. Can not proceed"

    Going forward to solve the issue...

    I was just thinking about this if you had any progress. :smile:

    Sounds like... Some progress. Let us know how it works out!

    Eric Duncan - UP Evangelist - My thoughts are of my own free will

    Answered? Please remember to mark the posted answered to highlight it for future visitors!

  • TimoK93
    TimoK93 New Member Posts: 27 ✭✭

    Im not sure how to convert the custom layers from the model i use... Did you ever worked with OpenVINO and converted custom layers?

  • eduncan911
    eduncan911 Administrator, Moderator Posts: 157 admin

    @TimoK93 said:
    Im not sure how to convert the custom layers from the model i use... Did you ever worked with OpenVINO and converted custom layers?

    Not yet. I'm still on some other testing at this moment, waiting on my AI Vision kit to arrive to do that work on.

    Eric Duncan - UP Evangelist - My thoughts are of my own free will

    Answered? Please remember to mark the posted answered to highlight it for future visitors!

  • AdamMiltonBarker
    AdamMiltonBarker New Member Posts: 20

    Don't bother trying to install TF2 from source, absolute joke, we are stuck to using 1.5.

    Repository rule git_repository defined at:
      /home/up2b/.cache/bazel/_bazel_up2b/0ca4081be8dbd8464fb732c761963c6e/external/bazel_tools/tools/build_defs/repo/git.bzl:195:18: in <toplevel>
    WARNING: Download from https://mirror.bazel.build/github.com/aws/aws-sdk-cpp/archive/1.7.336.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
    WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/f0bab7875e78e01c149d12302dcc4b6d4c43e25c.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
    WARNING: /home/up2b/tensorflow/tensorflow/core/BUILD:1775:1: in linkstatic attribute of cc_library rule //tensorflow/core:lib_headers_for_pybind: setting 'linkstatic=1' is recommended if there are no object files. Since this rule was created by the macro 'cc_library', the error might have been caused by the macro implementation
    WARNING: /home/up2b/tensorflow/tensorflow/core/BUILD:1750:1: in linkstatic attribute of cc_library rule //tensorflow/core:lib_internal: setting 'linkstatic=1' is recommended if there are no object files. Since this rule was created by the macro 'cc_library', the error might have been caused by the macro implementation
    WARNING: /home/up2b/tensorflow/tensorflow/core/BUILD:2162:1: in linkstatic attribute of cc_library rule //tensorflow/core:framework_internal: setting 'linkstatic=1' is recommended if there are no object files. Since this rule was created by the macro 'tf_cuda_library', the error might have been caused by the macro implementation
    WARNING: /home/up2b/tensorflow/tensorflow/python/BUILD:4666:1: in py_library rule //tensorflow/python:standard_ops: target '//tensorflow/python:standard_ops' depends on deprecated target '//tensorflow/python/ops/distributions:distributions': TensorFlow Distributions has migrated to TensorFlow Probability (https://github.com/tensorflow/probability). Deprecated copies remaining in tf.distributions will not receive new features, and will be removed by early 2019. You should update all usage of `tf.distributions` to `tfp.distributions`.
    WARNING: /home/up2b/tensorflow/tensorflow/python/BUILD:115:1: in py_library rule //tensorflow/python:no_contrib: target '//tensorflow/python:no_contrib' depends on deprecated target '//tensorflow/python/ops/distributions:distributions': TensorFlow Distributions has migrated to TensorFlow Probability (https://github.com/tensorflow/probability). Deprecated copies remaining in tf.distributions will not receive new features, and will be removed by early 2019. You should update all usage of `tf.distributions` to `tfp.distributions`.
    INFO: Analyzed target //tensorflow/tools/pip_package:build_pip_package (382 packages loaded, 30873 targets configured).
    INFO: Found 1 target...
    ERROR: /home/up2b/tensorflow/tensorflow/core/util/BUILD:351:1: error executing shell command: '/bin/bash -c bazel-out/k8-opt-exec-50AE0418-ST-e0f78fafe98f9cd48032f8d6a9732902b210aba3b30f85849d3455fe9d9fb327/bin/tensorflow/tools/git/gen_git_source --generate "$@" --git_tag_override=${GIT_TAG_...' failed (Exit 127)
    /usr/bin/env: 'python': No such file or directory
    Target //tensorflow/tools/pip_package:build_pip_package failed to build
    Use --verbose_failures to see the command lines of failed build steps.
    INFO: Elapsed time: 192.756s, Critical Path: 0.21s
    INFO: 0 processes.
    FAILED: Build did NOT complete successfully
    

Tagged