New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using bazel to cross-compile tensorflow for other targets. #1353

Closed
sachinpro opened this Issue Jun 8, 2016 · 71 comments

Comments

Projects
None yet
@sachinpro

sachinpro commented Jun 8, 2016

I compiled the tensorflow source using https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/label_image example for C++ on Ubuntu 14.04. Now I want to learn how to cross-compile for some other target architecture. I started with ARM. I installed the arm-linux-gnueabi-gcc tools and edited the bazel/tools/cpp/CROSSTOOL.tpl file and its android toolchain for the armeabi-v7a cpu, so that, my new toolchain looks like this :

toolchain {
abi_version: "armeabi-v7a"
abi_libc_version: "armeabi-v7a"
builtin_sysroot: ""
compiler: "compiler"
host_system_name: "armeabi-v7a"
needsPic: true
supports_gold_linker: false
supports_incremental_linker: false
supports_fission: false
supports_interface_shared_objects: false
supports_normalizing_ar: false
supports_start_end_lib: false
supports_thin_archives: false
target_libc: "armeabi-v7a"
target_cpu: "armeabi-v7a"
target_system_name: "armeabi-v7a"
toolchain_identifier: "stub_armeabi-v7a"

tool_path { name: "ar" path: "/usr/bin/arm-linux-gnueabi-ar" }
tool_path { name: "compat-ld" path: "/bin/false" }
tool_path { name: "cpp" path: "/usr/bin/arm-linux-gnueabi-cpp" }
tool_path { name: "dwp" path: "/bin/false" }
tool_path { name: "gcc" path: "/usr/bin/arm-linux-gnueabi-gcc" }
tool_path { name: "gcov" path: "/bin/false" }
tool_path { name: "ld" path: "/usr/bin/arm-linux-gnueabi-ld" }

tool_path { name: "nm" path: "/bin/false" }
tool_path { name: "objcopy" path: "/bin/false" }
tool_path { name: "objdump" path: "/bin/false" }
tool_path { name: "strip" path: "/bin/false" }
linking_mode_flags { mode: DYNAMIC }
}

But, when compiling tensorflow label_image using the command $bazel build --cpu=armeabi-v7a -s tensorflow/examples/label_image/... , I get an error:

INFO: Found 2 targets...
ERROR: /home/sachin/.cache/bazel/bazel_sachin/dc84bb70b01d0f4a792c48d02549c4f8/external/highwayhash/BUILD:17:1: C++ compilation of rule '@highwayhash//:sip_hash' failed: arm-linux-gnueabi-gcc failed: error executing command /usr/bin/arm-linux-gnueabi-gcc '-frandom-seed=bazel-out/stub_armeabi-v7a-fastbuild/bin/external/highwayhash/objs/sip_hash/external/highwayhash/highwayhash/sip_hash.pic.o' -fPIC -iquote ... (remaining 20 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
In file included from external/highwayhash/highwayhash/sip_hash.h:23:0,
from external/highwayhash/highwayhash/sip_hash.cc:15:
external/highwayhash/highwayhash/state_helpers.h: In function 'void highwayhash::UpdateState(const char
, highwayhash::uint64, State
)':
external/highwayhash/highwayhash/state_helpers.h:36:76: error: there are no arguments to 'static_assert' that depend on a template parameter, so a declaration of 'static_assert' must be available [-fpermissive]
external/highwayhash/highwayhash/state_helpers.h:36:76: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
In file included from external/highwayhash/highwayhash/sip_hash.cc:15:0:
external/highwayhash/highwayhash/sip_hash.h: At global scope:
external/highwayhash/highwayhash/sip_hash.h:31:9: error: expected nested-name-specifier before 'Key'
external/highwayhash/highwayhash/sip_hash.h:31:9: error: using-declaration for non-member at class scope
external/highwayhash/highwayhash/sip_hash.h:31:13: error: expected ';' before '=' token
external/highwayhash/highwayhash/sip_hash.h:31:13: error: expected unqualified-id before '=' token

I am pretty clueless about these errors and I am new to bazel. Is there anything more I have to do?If yes, can someone tell me what steps I have to follow to have my build for different architectures? I am using bazel 0.2.3.

Thanks in advance.

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 8, 2016

Here is the wiki page about how to use a custom toolchain, and the example might be very close to what you need. :)
https://github.com/bazelbuild/bazel/wiki/Building-with-a-custom-toolchain

@sachinpro

This comment has been minimized.

sachinpro commented Jun 8, 2016

Thanks. I will try this . :)

@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

The link you gave me helped to a great extent. I have setup everything exactly according to the tutorial, I am just confused about the heirarchy of the tree . My current structure for the tools directory is in the attachment .
structure.txt

In the same folder, there is my WORKSPACE file and another folder linaro_linux_gcc_4.9_repo/ which contains all the binaries.

There is a file ./compilers/linaro_linux_gcc_4.9.BUILD .

In my WORSPACE file, I added:

new_http_archive(
name = "linaro_linux_gcc_4.9_repo",
build_file = "compilers/linaro_linux_gcc_4.9.BUILD",
sha256 = '25e97bcb0af4fd7cd626d5bb1b303c7d2cb13acf2474e335e3d431d1a53fbb52',
url = 'http://localhost:8000/gcc-linaro-4.9-2015.05-x86_64_arm-linux-gnueabihf.tar.gz',
)

But when compile using command "$bazel build --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a tensorflow/examples/label_image/..." , I get the following error:

ERROR: /home/sachin/Downloads/tensorflow/WORKSPACE:420:1: new_http_archive rule //external:linaro_linux_gcc_4.9_repo's name field must be a legal workspace name.
ERROR: Error evaluating WORKSPACE file.
ERROR: package contains errors: tensorflow/examples/label_image.
ERROR: error loading package 'external': Package 'external' contains errors.
INFO: Elapsed time: 0.135s

There must be something wrong with my directory structure , but I don't know what.

@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

Where should I put my linaro_linux_gcc_4.9_repo folder? I think the problem is with the location of this folder only.

@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

I removed the error I mentioned above and after making a few changes in my WORKSPACE and CROSSTOOL file, I am getting the following error:

ERROR: The toolchain rule '//tools/arm_compiler:cc-compiler-local' does not exist.

Please help me with this.

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 9, 2016

The error is actually as the error messages said linaro_linux_gcc_4.9_repo is not a valid workspace name, linaro_linux_gcc_repo works for me. We should update the wiki page, sorry for that.

But using new_http_archive still seems to be a little bit trouble, because there is no usable url for downloading.
However, you can decompress gcc-linaro-4.9-2015.05-x86_64_arm-linux-gnueabihf.tar.gz into a folder, and then use new_local_repository.
Like this:

pcloudy@pcloudy0 ~/workspace/bazel_local_repository
$ tree -L 2 .
.
├── BUILD
├── compilers
│   ├── gcc-linaro-4.9-2015.05-x86_64_arm-linux-gnueabihf
│   └── linaro_linux_gcc_4.9.BUILD
└── WORKSPACE

2 directories, 3 files
pcloudy@pcloudy0 ~/workspace/bazel_local_repository
$ cat WORKSPACE 
new_local_repository(
    name = 'linaro_linux_gcc_repo',
    build_file = 'compilers/linaro_linux_gcc_4.9.BUILD',
    path = 'compilers/gcc-linaro-4.9-2015.05-x86_64_arm-linux-gnueabihf',
)
pcloudy@pcloudy0 ~/workspace/bazel_local_repository
$ cat BUILD 

filegroup(
    name = "test",
    srcs = ["@linaro_linux_gcc_repo//:gcc"],
)

cc_binary(
    name = "hello",
    srcs = ["hello.cc"],
    data = [":test"],
)
pcloudy@pcloudy0 ~/workspace/bazel_local_repository
$ bazel build :hello
INFO: Found 1 target...
Target //:hello up-to-date:
  bazel-bin/hello
INFO: Elapsed time: 0.782s, Critical Path: 0.53s

Hope this can help you. :)

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 9, 2016

OK.. Can you show me your CROSSTOOL file?

@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

I also removed the error using linaro_linux_gcc_repo instead. CROSSTOOL file is attached.
CROSSTOOL.txt

@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

I added the k8 toolchain because it was giving an error "cpu k8 is not supported" . And I am currently using my git repository to download the binaries by adding this in my WORKSPACE file:

new_git_repository(
name = "linaro_linux_gcc_repo",
build_file = "compilers/linaro_linux_gcc_4.9.BUILD",
remote = "https://github.com/sachinpro/sachinpro.github.io.git",
#tag = "",
commit="4e1c212901bf72e8b3def5bb3bcb84fdffb75592"
)

But I will try what you are telling too.

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 9, 2016

And what is the command line giving this error?

@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

sachin@sachin-pc:~/Downloads/tensorflow$ bazel build --crosstool_top=//tools/arm_compiler:toolchain --verbose_failures --sandbox_debug --cpu=armeabi-v7a tensorflow/examples/label_image/...
ERROR: No toolchain found for cpu 'k8'. Valid cpus are: [
armeabi-v7a,
].
INFO: Elapsed time: 1.240s

This is the error if I get when follow the original tutorial without adding the k8 toolchain. You are asking about this error only , right?

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 9, 2016

So after you add the k8 toolchain, the same command gave this error ?
ERROR: The toolchain rule '//tools/arm_compiler:cc-compiler-local' does not exist.

@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

Yes, exactly.

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 9, 2016

Oh, yeah, I was just trying to show how new_local_repository works.

And how about the BUILD file, I think you should also modify it.
Maybe it's missing this:

cc_toolchain(
    name = "cc-compiler-local",
    all_files = ":empty",
    compiler_files = ":empty",
    cpu = "local",
    dwp_files = ":empty",
    dynamic_runtime_libs = [":empty"],
    linker_files = ":empty",
    objcopy_files = ":empty",
    static_runtime_libs = [":empty"],
    strip_files = ":empty",
    supports_param_files = 1,
)
@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

Here is my current WORKSPACE file .
WORKSPACE.txt

@sachinpro sachinpro closed this Jun 9, 2016

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 9, 2016

I mean the BUILD file next to the CROSSTOOL.
Like this one: https://github.com/bazelbuild/bazel/wiki/Building-with-a-custom-toolchain#writing-the-build-file

Did you accidentally close this issue?

@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

Which BUILD file are you talking about? I have BUILD files present in ./tools/arm_compiler , ./tools/arm_compiler/linaro_linux_gcc and another for my label_image example.

@sachinpro sachinpro reopened this Jun 9, 2016

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 9, 2016

Should be tools/arm_compiler/BUILD

@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

Sorry for closing, it was by mistake. I just added the cc_toolchain() you told me to and now there is a new error:

sachin@sachin-pc:~/Downloads/tensorflow$ bazel build --crosstool_top=//tools/arm_compiler:toolchain --verbose_failures --sandbox_debug --cpu=armeabi-v7a tensorflow/examples/label_image/...
ERROR: /home/sachin/.cache/bazel/_bazel_sachin/dc84bb70b01d0f4a792c48d02549c4f8/external/bazel_tools/tools/cpp/BUILD:7:1: Target '//tools/arm_compiler:cc-compiler-armeabi-v7a' is not visible from target '@bazel_tools//tools/cpp:stl'. Check the visibility declaration of the former target if you think the dependency is legitimate.
ERROR: Analysis of target '//tensorflow/examples/label_image:label_image' failed; build aborted.

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 9, 2016

Add package(default_visibility = ["//visibility:public"]) to the same BUILD file

@sachinpro

This comment has been minimized.

sachinpro commented Jun 9, 2016

Now i get the following error:

ERROR: /home/sachin/Downloads/tensorflow/tensorflow/cc/BUILD:28:1: //tensorflow/cc:cc_ops: missing input file '//tools/arm_compiler/linaro_linux_gcc:clang_bin/as'.
ERROR: /home/sachin/Downloads/tensorflow/tensorflow/cc/BUILD:28:1 1 input file(s) do not exist.

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 9, 2016

Follow the error message, check if tools/arm_compiler/linaro_linux_gcc/clang_bin/as exists?

@changyun79

This comment has been minimized.

changyun79 commented Jun 9, 2016

I am new to bazel too but trying to do the same thing so just want to give you some head up that tensor flow is using protocol buffer 3.0.0 beta2 which you may need to cross compile first.
It can be done by pretty much following this with some minor updates:
https://github.com/eurotech/edc-examples/wiki/Cross-compiling-protobuf-for-ARM-architecture

I am going to be on tensor flow this weekend.

@sachinpro

This comment has been minimized.

sachinpro commented Jun 10, 2016

There is just a 'clang' file, in clang_bin, but no tools/arm_compiler/linaro_linux_gcc/clang_bin/as or ld exists. Can you please tell me how to create those symlinks as mentioned in https://github.com/bazelbuild/bazel/wiki/Building-with-a-custom-toolchain#writing-the-wrapper-scripts ? Where should they point to?

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 10, 2016

You should create a wrapper script at tools/arm_compiler/linaro_linux_gcc/arm-linux-gnueabihf-as for as. Should be similar to this:

#!/bin/bash --norc

exec -a arm-linux-gnueabihf-nm \
    external/linaro_linux_gcc_4.9_repo/bin/arm-linux-gnueabihf-nm \
    "$@"

And create a symlink tools/arm_compiler/linaro_linux_gcc/clang_bin/as pointing to the wrapper script.

@sachinpro

This comment has been minimized.

sachinpro commented Jun 10, 2016

Done that. Now error again:

ERROR: missing input file '//tools/arm_compiler:empty'.
ERROR: /home/sachin/Downloads/tensorflow/tensorflow/cc/BUILD:28:1: //tensorflow/cc:ops/training_ops_gen_cc: missing input file '//tools/arm_compiler:empty'.
ERROR: /home/sachin/Downloads/tensorflow/tensorflow/cc/BUILD:28:1 1 input file(s) do not exist.
INFO: Elapsed time: 70.388s, Critical Path: 5.72s

@meteorcloudy

This comment has been minimized.

Member

meteorcloudy commented Jun 10, 2016

I think you can just create the missing file, it might doesn't do anything, but it's required by Bazel.

@sachinpro

This comment has been minimized.

sachinpro commented Jun 10, 2016

Thanks , next ERROR :
config.status: executing depfiles commands
config.status: executing libtool commands
/home/sachin/.cache/bazel/bazel_sachin/dc84bb70b01d0f4a792c48d02549c4f8/execroot/tensorflow/external/jpeg_archive/jpeg-9a /home/sachin/.cache/bazel/bazel_sachin/dc84bb70b01d0f4a792c48d02549c4f8/execroot/tensorflow
/home/sachin/.cache/bazel/bazel_sachin/dc84bb70b01d0f4a792c48d02549c4f8/execroot/tensorflow
ERROR: /home/sachin/.cache/bazel/bazel_sachin/dc84bb70b01d0f4a792c48d02549c4f8/external/protobuf/BUILD:111:1: C++ compilation of rule '@protobuf//:protobuf' failed: clang failed: error executing command
(cd /home/sachin/.cache/bazel/bazel_sachin/dc84bb70b01d0f4a792c48d02549c4f8/execroot/tensorflow &&
exec env -
PATH=/home/sachin/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/java/jdk1.8.0_74/bin:/usr/local/java/jdk1.8.0_74/jre/bin:/home/sachin/bazel/bazel-bin/src/:/home/sachin/bazel/output/
tools/arm_compiler/linaro_linux_gcc/clang_bin/clang -target armv7a-arm-linux-gnueabif '--sysroot=external/linaro_linux_gcc_repo/arm-linux-gnueabihf/libc' '-mfloat-abi=hard' -nostdinc -isystem /usr/lib/clang/3.6/include -isystem external/linaro_linux_gcc_repo/lib/gcc/arm-linux-gnueabihf/4.9.3/include -isystem external/linaro_linux_gcc_repo/arm-linux-gnueabihf/libc/usr/include -isystem external/linaro_linux_gcc_repo/lib/gcc/arm-linux-gnueabihf/4.9.3/include-fixed -isystem external/linaro_linux_gcc_repo/arm-linux-gnueabihf/libc/usr/include -U_FORTIFY_SOURCE -fstack-protector -fPIE '-fdiagnostics-color=always' -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -isystem external/linaro_linux_gcc_repo/arm-linux-gnueabihf/include/c++/4.9.3/arm-linux-gnueabihf -isystem external/linaro_linux_gcc_repo/arm-linux-gnueabihf/include/c++/4.9.3 -isystem external/linaro_linux_gcc_repo/include/c++/4.9.3/arm-linux-gnueabihf -isystem external/linaro_linux_gcc_repo/include/c++/4.9.3 '-frandom-seed=bazel-out/clang_linux_armhf-fastbuild/bin/external/protobuf/objs/protobuf/external/protobuf/src/google/protobuf/any.pic.o' -fPIC -iquote external/protobuf -iquote bazel-out/clang_linux_armhf-fastbuild/genfiles/external/protobuf -iquote external/bazel_tools -iquote bazel-out/clang_linux_armhf-fastbuild/genfiles/external/bazel_tools -isystem external/protobuf/src -isystem bazel-out/clang_linux_armhf-fastbuild/genfiles/external/protobuf/src -isystem external/bazel_tools/tools/cpp/gcc3 -DHAVE_PTHREAD -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare '-Wno-error=unused-function' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE
="redacted"' '-D__TIMESTAMP
="redacted"' '-D__TIME
="redacted"' -MD -MF bazel-out/clang_linux_armhf-fastbuild/bin/external/protobuf/_objs/protobuf/external/protobuf/src/google/protobuf/any.pic.d -c external/protobuf/src/google/protobuf/any.cc -o bazel-out/clang_linux_armhf-fastbuild/bin/external/protobuf/_objs/protobuf/external/protobuf/src/google/protobuf/any.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
process-wrapper: execvp("tools/arm_compiler/linaro_linux_gcc/clang_bin/clang", ...): Permission denied
INFO: Elapsed time: 135.534s, Critical Path: 68.99s

@uvaidya

This comment has been minimized.

uvaidya commented Jun 28, 2016

For error mentioned above , do we need to have a change like
filegroup( name = 'clang-as', srcs = [ 'clang_bin/as', ':as', ], )
In tools/arm_compiler/linaro_linux_gcc/BUILD ?

@sachinpro

This comment has been minimized.

sachinpro commented Jun 28, 2016

Did you copy your arm toolchain to ./compilers ??

@uvaidya

This comment has been minimized.

uvaidya commented Jun 28, 2016

I copied gcc-linaro-4.9-2015.05-x86_64_arm-linux-gnueabihf , which was mentioned in https://github.com/bazelbuild/bazel/wiki/Building-with-a-custom-toolchain in compilers .

command used is :
bazel build --crosstool_top=//tools/arm_compiler:toolchain --verbose_failures --sandbox_debug --cpu=armeabi-v7a tensorflow/examples/label_image/...

@sachinpro

This comment has been minimized.

sachinpro commented Jun 28, 2016

Make the symlinks /tools/arm_compiler/linaro_linux_gcc/clang_bin/as and /tools/arm_compiler/linaro_linux_gcc/clang_bin/ld point to /tools/arm_compiler/linaro_linux_gcc/clang_bin/arm-linux-gnueabihf-as and /tools/arm_compiler/linaro_linux_gcc/clang_bin/arm-linux-gnueabihf-ld respectively .
I forgot to keep this in mind. This should work.

@uvaidya

This comment has been minimized.

uvaidya commented Jun 28, 2016

Sure will do this, and let you know
Thanks

@uvaidya

This comment has been minimized.

uvaidya commented Jun 28, 2016

did this :
ln -s tools/arm_compiler/linaro_linux_gcc/clang_bin/as tools/arm_compiler/linaro_linux_gcc/clang_bin/arm-linux-gnueabihf-as
ln -s tools/arm_compiler/linaro_linux_gcc/clang_bin/ld tools/arm_compiler/linaro_linux_gcc/clang_bin/arm-linux-gnueabihf-ld

But got same error ...

@uvaidya

This comment has been minimized.

uvaidya commented Jun 28, 2016

Hi Sachin
made mistake in above command , basically the wrapper scripts in arm_compiler should be pointed to by a symlink inside clang-bin right ? Also to create symlink in another folder , we need to give full path of file .
After doing above atleast above mentioned error is not seen. :-) .
Thanks for pointing it out .

@sachinpro

This comment has been minimized.

sachinpro commented Jun 28, 2016

Yes , you need to give full path. Are there any more errors?

@uvaidya

This comment has been minimized.

uvaidya commented Jun 28, 2016

Build is going on , will let you know once its finished .

@uvaidya

This comment has been minimized.

uvaidya commented Jun 28, 2016

Compilation got completed successfully .Thanks Sachin.
one more thing,
Now this binary should run on arm based android device, right ?

I pushed it to android device under system/bin
did chmod +x also , but when gave label_image as an argument for execution of file it returned error:
"No such file or directory" .
Have you executed this binary on arm based android device ?

Thanks

@sachinpro

This comment has been minimized.

sachinpro commented Jun 28, 2016

I have not yet executed this binary on an arm device. I am working on it . Will let you know when I have done that.

@uvaidya

This comment has been minimized.

uvaidya commented Jun 28, 2016

ok , Please let me know .
Thanks

@uvaidya

This comment has been minimized.

uvaidya commented Jun 30, 2016

Hi SachinPro ,

I checked binary created with cross compilation when performed with arm toolchain , details of file goes as follows :-
_ ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, BuildID[md5/uuid]=0xf2fe70777ae59604b558c8c774fb5148, not stripped_

details of default binary, which we build with bazel build //project_path is :-

ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[md5/uuid]=0x19510cf66ad7bedd2213e43a4f4e8ad1, not stripped

binary for arm is not executable instead its shared object .What needs to be done to make arm binary executable ?
Do we need to have some change in toolchain which we made referring to https://github.com/bazelbuild/bazel/wiki/Building-with-a-custom-toolchain ?

@sachinpro

This comment has been minimized.

sachinpro commented Jun 30, 2016

Read this http://askubuntu.com/questions/690631/executables-vs-shared-objects . As such, there is no difference between them.

@ghost

This comment has been minimized.

ghost commented Sep 4, 2016

Did you ever succeed with this? I'm in a similar predicament, except I'm compiling another piece of deep learning code, not TensorFlow. Google should get its act together on this and start making sure its publicly released stuff builds with ARM and POWER. I know they do this internally, so it shouldn't be that much work.

@rasmi

This comment has been minimized.

rasmi commented Sep 5, 2016

I'm also running into a similar error with external/highwayhash/highwayhash/state_helpers.h. Opened an issue for my particular error here.

@vikas1981

This comment has been minimized.

vikas1981 commented Jan 21, 2017

I am seeing this error:

ERROR: /home/ec2-user/src/tensorflow/tensorflow/core/BUILD:829:1: undeclared inclusion(s) in rule '//tensorflow/core:lib_internal':
this rule is missing dependency declarations for the following files included by 'tensorflow/core/lib/png/png_io.cc':
'/root/.cache/bazel/_bazel_root/2b8dc63c6c17d4d5be378207b06795d6/external/zlib_archive/zlib.h'
'/root/.cache/bazel/_bazel_root/2b8dc63c6c17d4d5be378207b06795d6/external/zlib_archive/zconf.h'.
In file included from /usr/include/string.h:25:0,
from tensorflow/core/lib/png/png_io.cc:18:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]

warning _FORTIFY_SOURCE requires compiling with optimization (-O)

^

Target //tensorflow/examples/image_retraining:retrain failed to build

@rasmi

This comment has been minimized.

rasmi commented Jan 21, 2017

@vikas1981 it seems you're missing zlib headers. Try running sudo apt-get install zlib1g-dev and running the build again.

@vikas1981

This comment has been minimized.

vikas1981 commented Jan 21, 2017

Thanks for replying:
zlib is already installed

Loaded plugins: dkms-build-requires, priorities, update-motd, upgrade-helper
980 packages excluded due to repository priority protections
Package zlib-devel-1.2.8-7.18.amzn1.x86_64 already installed and latest version
Nothing to do

@rasmi

This comment has been minimized.

rasmi commented Jan 22, 2017

@vikas1981 What build command are you using? Make sure you include -c opt in your bazel build command.

bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
@StephenLeeUSTC

This comment has been minimized.

StephenLeeUSTC commented Feb 8, 2017

@uvaidya @uvaidya Wow, i am doing almost the same thing as you two!!!
And, could you please tell me the basic version of tensorflow in https://github.com/sachinpro/sachinpro.github.io.git? thanks

@madhutummi

This comment has been minimized.

madhutummi commented Apr 5, 2017

@rasmi I am getting similiar error reported by @vikas1981 , but I do not "get warning _FORTIFY_SOURCE" warning

I am using bazel 3.0.2 with customized TF.

Can you please help?

Hi @vikas1981 your issue got fixed?

"ERROR: tensorflow/core/BUILD:853:1: undeclared inclusion(s) in rule '//tensorflow/core:lib_internal':
this rule is missing dependency declarations for the following files included by 'tensorflow/core/lib/png/png_io.cc':
~/.cache/bazel/_bazel_madhu/a9aabe45cf3d94341ef4fb777deb58c5/external/zlib_archive/zlib.h'
~/.cache/bazel/_bazel_madhu/a9aabe45cf3d94341ef4fb777deb58c5/external/zlib_archive/zconf.h'."

@mhlopko

This comment has been minimized.

Contributor

mhlopko commented Sep 5, 2017

I'll close this issue now, I think it's more of a discussion thread than an issue. Feel free to continue on bazel-discuss or stack overflow. Thanks everybody!

@mhlopko mhlopko closed this Sep 5, 2017

@gopinath-r

This comment has been minimized.

gopinath-r commented Sep 6, 2017

Hi,
I have followed all the steps provided above and now i am getting this error.
/home/gopinathr/Documents/work/tensorflow/tools/arm_compiler/BUILD:51:1: in cc_toolchain rule //tools/arm_compiler:cc-compiler-armeabi-v7a: The package '@linaro_linux_gcc_repo' is not valid

I am trying to build tensorflow as a pip package using cross compiler toolchains.

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

Build, Crosstool, Workspace file i am using are
WORKSPACE.txt
BUILD.txt
CROSSTOOL.txt

Could anyone help out what is wrong in my setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment