我正在尝试在 ARM 板上安装 TensorFlow(我的平台是:)通过使用和编译器ODROID XU4
进行交叉编译。我已经完成了以下步骤:bazel
linaro
- 为 armeabihf 下载 Linaro 4.9.4
- 将此行添加到 WORKSPACE 文件
new_local_repository(
name = 'toolchain_target_arm_linux_gnueabihf',
path = '/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf',
build_file = 'arm-compiler/cross_toolchain_target_arm_linux_gnueabihf_host_x86-64.BUILD'
- 并创建 CROSSTOOL、BUILD 和 cross_toolchain_target_arm_linux_gnueabi_host_x86-64.BUILD 文件,如下所示:
- 手臂编译/构建:
package(default_visibility = ["//visibility:public"])
cc_toolchain_suite(
name = "toolchain",
toolchains = {
"armeabi-v7a|compiler": ":cc-compiler-armeabi",
"k8|compiler": ":cc-compiler-local",
},
)
filegroup(
name = "empty",
srcs = [],
)
filegroup(
name = "arm_linux_all_files",
srcs = [
"@toolchain_target_arm_linux_gnueabi//:compiler_pieces",
],
)
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,
)
cc_toolchain(
name = "cc-compiler-armeabi",
all_files = ":arm_linux_all_files",
compiler_files = ":arm_linux_all_files",
cpu = "armeabi-v7a",
dwp_files = ":empty",
dynamic_runtime_libs = [":empty"],
linker_files = ":arm_linux_all_files",
objcopy_files = "arm_linux_all_files",
static_runtime_libs = [":empty"],
strip_files = "arm_linux_all_files",
supports_param_files = 1,
)
- 手臂编译/交叉工具:
major_version: "local"
minor_version: ""
default_target_cpu: "armeabi-v7a"
default_toolchain {
cpu: "armeabi-v7a"
toolchain_identifier: "gcc-linaro-4.9.4"
}
default_toolchain {
cpu: "k8"
toolchain_identifier: "local"
}
toolchain {
abi_version: "armeabi-v7a"
abi_libc_version: "glibc_2.19"
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: true
supports_start_end_lib: false
supports_thin_archives: true
target_libc: "glibc_2.19"
target_cpu: "armeabi-v7a"
target_system_name: "armeabi-v7a"
toolchain_identifier: "gcc-linaro-4.9.4"
tool_path { name: "ar" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar" }
tool_path { name: "compat-ld" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ld" }
tool_path { name: "cpp" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-cpp" }
tool_path { name: "dwp" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-dwp" }
tool_path { name: "gcc" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc" }
tool_path { name: "gcov" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcov" }
tool_path { name: "ld" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ld" }
tool_path { name: "nm" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-nm" }
tool_path { name: "objcopy" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-objcopy" }
objcopy_embed_flag: "-I"
objcopy_embed_flag: "binary"
tool_path { name: "objdump" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-objdump" }
tool_path { name: "strip" path: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip" }
compiler_flag: "--sysroot=/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/"
compiler_flag: "-mfloat-abi=hard"
cxx_builtin_include_directory: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include"
cxx_builtin_include_directory: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include"
cxx_builtin_include_directory: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/include"
cxx_builtin_include_directory: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/4.9.3/include-fixed"
cxx_builtin_include_directory: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/include/c++/4.9.4"
cxx_builtin_include_directory: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/4.9.3/include"
cxx_builtin_include_directory: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/4.9.3/include-fixed"
cxx_builtin_include_directory: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/lib/gcc/arm-linux-gnueabihf/4.9.4/include"
cxx_builtin_include_directory: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/lib/gcc/arm-linux-gnueabihf/4.9.4/include-fixed"
cxx_builtin_include_directory: "/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include)%/c++/4.9.4"
linker_flag: "--sysroot=/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/"
linker_flag: "-lstdc++"
linker_flag: "-L/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/lib"
linker_flag: "-L/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib"
linker_flag: "-L/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib"
linker_flag: "-B/home/system/Clones/CrossCompileTF/toolchain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/bin"
# Anticipated future default.
# This makes GCC and Clang do what we want when called through symlinks.
unfiltered_cxx_flag: "-no-canonical-prefixes"
linker_flag: "-no-canonical-prefixes"
# Make C++ compilation deterministic. Use linkstamping instead of these
# compiler symbols.
unfiltered_cxx_flag: "-Wno-builtin-macro-redefined"
unfiltered_cxx_flag: "-D__DATE__=\"redacted\""
unfiltered_cxx_flag: "-D__TIMESTAMP__=\"redacted\""
unfiltered_cxx_flag: "-D__TIME__=\"redacted\""
# Security hardening on by default.
# Conservative choice; -D_FORTIFY_SOURCE=2 may be unsafe in some cases.
# We need to undef it before redefining it as some distributions now have
# it enabled by default.
compiler_flag: "-U_FORTIFY_SOURCE"
compiler_flag: "-fstack-protector"
compiler_flag: "-fPIE"
linker_flag: "-pie"
linker_flag: "-Wl,-z,relro,-z,now"
# Enable coloring even if there's no attached terminal. Bazel removes the
# escape sequences if --nocolor is specified.
compiler_flag: "-fdiagnostics-color=always"
# All warnings are enabled. Maybe enable -Werror as well?
compiler_flag: "-Wall"
# Enable a few more warnings that aren't part of -Wall.
compiler_flag: "-Wunused-but-set-parameter"
# But disable some that are problematic.
compiler_flag: "-Wno-free-nonheap-object" # has false positives
# Keep stack frames for debugging, even in opt mode.
compiler_flag: "-fno-omit-frame-pointer"
# Stamp the binary with a unique identifier.
linker_flag: "-Wl,--build-id=md5"
linker_flag: "-Wl,--hash-style=gnu"
compilation_mode_flags {
mode: DBG
# Enable debug symbols.
compiler_flag: "-g"
}
compilation_mode_flags {
mode: OPT
# No debug symbols.
# Maybe we should enable https://gcc.gnu.org/wiki/DebugFission for opt or
# even generally? However, that can't happen here, as it requires special
# handling in Bazel.
compiler_flag: "-g0"
# Conservative choice for -O
# -O3 can increase binary size and even slow down the resulting binaries.
# Profile first and / or use FDO if you need better performance than this.
compiler_flag: "-O2"
# Disable assertions
compiler_flag: "-DNDEBUG"
# Removal of unused code and data at link time (can this increase binary size in some cases?).
compiler_flag: "-ffunction-sections"
compiler_flag: "-fdata-sections"
linker_flag: "-Wl,--gc-sections"
}
}
toolchain {
toolchain_identifier: "local"
abi_libc_version: "local"
abi_version: "local"
builtin_sysroot: ""
compiler: "compiler"
compiler_flag: "-U_FORTIFY_SOURCE"
compiler_flag: "-D_FORTIFY_SOURCE=2"
compiler_flag: "-fstack-protector"
compiler_flag: "-Wall"
compiler_flag: "-Wl,-z,-relro,-z,now"
compiler_flag: "-B/usr/bin"
compiler_flag: "-B/usr/bin"
compiler_flag: "-Wunused-but-set-parameter"
compiler_flag: "-Wno-free-nonheap-object"
compiler_flag: "-fno-omit-frame-pointer"
cxx_builtin_include_directory: "/usr/include/c++/5"
cxx_builtin_include_directory: "/usr/include/x86_64-linux-gnu/c++/5"
cxx_builtin_include_directory: "/usr/include/c++/5/backward"
cxx_builtin_include_directory: "/usr/lib/gcc/x86_64-linux-gnu/5/include"
cxx_builtin_include_directory: "/usr/local/include"
cxx_builtin_include_directory: "/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed"
cxx_builtin_include_directory: "/usr/include/x86_64-linux-gnu"
cxx_builtin_include_directory: "/usr/include"
cxx_flag: "-std=c++0x"
host_system_name: "local"
linker_flag: "-lstdc++"
linker_flag: "-lm"
linker_flag: "-Wl,-no-as-needed"
linker_flag: "-B/usr/bin"
linker_flag: "-B/usr/bin"
linker_flag: "-pass-exit-codes"
needsPic: true
objcopy_embed_flag: "-I"
objcopy_embed_flag: "binary"
supports_fission: false
supports_gold_linker: false
supports_incremental_linker: false
supports_interface_shared_objects: false
supports_normalizing_ar: false
supports_start_end_lib: false
supports_thin_archives: false
target_cpu: "k8"
target_libc: "local"
target_system_name: "local"
unfiltered_cxx_flag: "-fno-canonical-system-headers"
unfiltered_cxx_flag: "-Wno-builtin-macro-redefined"
unfiltered_cxx_flag: "-D__DATE__=\"redacted\""
unfiltered_cxx_flag: "-D__TIMESTAMP__=\"redacted\""
unfiltered_cxx_flag: "-D__TIME__=\"redacted\""
tool_path {name: "ar" path: "/usr/bin/ar" }
tool_path {name: "cpp" path: "/usr/bin/cpp" }
tool_path {name: "dwp" path: "/usr/bin/dwp" }
tool_path {name: "gcc" path: "/usr/bin/gcc" }
tool_path {name: "gcov" path: "/usr/bin/gcov" }
tool_path {name: "ld" path: "/usr/bin/ld" }
tool_path {name: "nm" path: "/usr/bin/nm" }
tool_path {name: "objcopy" path: "/usr/bin/objcopy" }
tool_path {name: "objdump" path: "/usr/bin/objdump" }
tool_path {name: "strip" path: "/usr/bin/strip" }
compilation_mode_flags {
mode: DBG
compiler_flag: "-g"
}
compilation_mode_flags {
mode: OPT
compiler_flag: "-g0"
compiler_flag: "-O2"
compiler_flag: "-DNDEBUG"
compiler_flag: "-ffunction-sections"
compiler_flag: "-fdata-sections"
linker_flag: "-Wl,--gc-sections"
}
linking_mode_flags { mode: DYNAMIC }
}
- 臂编译/cross_toolchain_target_arm_linux_gnueabi_host_x86-64.BUILD:
package(default_visibility = ['//visibility:public'])
filegroup(
name = 'gcc',
srcs = [
'bin/arm-linux-gnueabi-gcc',
],
)
filegroup(
name = 'ar',
srcs = [
'bin/arm-linux-gnueabi-ar',
],
)
filegroup(
name = 'ld',
srcs = [
'bin/arm-linux-gnueabi-ld',
],
)
filegroup(
name = 'nm',
srcs = [
'bin/arm-linux-gnueabi-nm',
],
)
filegroup(
name = 'objcopy',
srcs = [
'bin/arm-linux-gnueabi-objcopy',
],
)
filegroup(
name = 'objdump',
srcs = [
'bin/arm-linux-gnueabi-objdump',
],
)
filegroup(
name = 'strip',
srcs = [
'bin/arm-linux-gnueabi-strip',
],
)
filegroup(
name = 'as',
srcs = [
'bin/arm-linux-gnueabi-as',
],
)
filegroup(
name = 'compiler_pieces',
srcs = glob([
'arm-linux-gnueabi/**',
'libexec/**',
'lib/gcc/arm-linux-gnueabi/**',
'include/**',
]),
)
filegroup(
name = 'compiler_components',
srcs = [
':gcc',
':ar',
':ld',
':nm',
':objcopy',
':objdump',
':strip',
':as',
],
)
- 运行此命令:
bazel build --crosstool_top=//arm-compiler:toolchain --cpu=armeabi-v7a --config=opt -s //tensorflow:libtensorflow_framework.so
不幸的是我在这个命令之后得到了错误,错误是:
ERROR: /home/system/Clones/tensorflow-1.15.2/arm-compiler/BUILD:23:1: //arm-compiler:cc-compiler-local: no such attribute 'dynamic_runtime_libs' in 'cc_toolchain' rule
ERROR: /home/system/Clones/tensorflow-1.15.2/arm-compiler/BUILD:23:1: //arm-compiler:cc-compiler-local: no such attribute 'static_runtime_libs' in 'cc_toolchain' rule
ERROR: /home/system/Clones/tensorflow-1.15.2/arm-compiler/BUILD:23:1: //arm-compiler:cc-compiler-local: missing value for mandatory attribute 'toolchain_config' in 'cc_toolchain' rule
ERROR: /home/system/Clones/tensorflow-1.15.2/arm-compiler/BUILD:37:1: //arm-compiler:cc-compiler-armeabi: no such attribute 'dynamic_runtime_libs' in 'cc_toolchain' rule
ERROR: /home/system/Clones/tensorflow-1.15.2/arm-compiler/BUILD:37:1: //arm-compiler:cc-compiler-armeabi: no such attribute 'static_runtime_libs' in 'cc_toolchain' rule
ERROR: /home/system/Clones/tensorflow-1.15.2/arm-compiler/BUILD:37:1: //arm-compiler:cc-compiler-armeabi: missing value for mandatory attribute 'toolchain_config' in 'cc_toolchain' rule
ERROR: /home/system/Clones/tensorflow-1.15.2/arm-compiler/BUILD:23:1: Target '//arm-compiler:empty' contains an error and its package is in error and referenced by '//arm-compiler:cc-compiler-local'
ERROR: /home/system/Clones/tensorflow-1.15.2/arm-compiler/BUILD:3:1: Target '//arm-compiler:cc-compiler-armeabi' contains an error and its package is in error and referenced by '//arm-compiler:toolchain'
ERROR: /home/system/Clones/tensorflow-1.15.2/arm-compiler/BUILD:3:1: Target '//arm-compiler:cc-compiler-local' contains an error and its package is in error and referenced by '//arm-compiler:toolchain'
ERROR: /home/system/Clones/tensorflow-1.15.2/tensorflow/BUILD:563:1: every rule of type cc_binary implicitly depends upon the target '//arm-compiler:toolchain', but this target could not be found because of: Target '//arm-compiler:toolchain' contains an error and its package is in error
ERROR: Analysis of target '//tensorflow:libtensorflow_framework.so' failed; build aborted: Analysis failed
INFO: Elapsed time: 11.124s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (4 packages loaded, 18 targets con\
figured)
我是交叉编译的初学者和困惑,请帮助和指导我。谢谢。