$ sudo apt-get install openjdk-8-jdk
$ sudo apt-get install pkg-config zip g++ zlib1g-dev unzip
$ wget https://github.com/bazelbuild/bazel/releases/download/0.4.4/bazel-0.4.4-dist.zip
$ mkdir bazel-0.4.4
$ unzip bazel-0.4.4-dist.zip -d bazel-0.4.4
$ cd bazel-0.4.4
因为使用的架构是 aarch64,所以修改bazel源文件
vim ./scripts/bootstrap/buildenv.sh
MACHINE_TYPE="$(uname -m)"
MACHINE_IS_64BIT='no'
-if [ "${MACHINE_TYPE}" = 'amd64' -o "${MACHINE_TYPE}" = 'x86_64' -o "${MACHINE_TYPE}" = 's390x' ]; then
+if [ "${MACHINE_TYPE}" = 'amd64' -o "${MACHINE_TYPE}" = 'x86_64' -o "${MACHINE_TYPE}" = 's390x' -o "${MACHINE_TYPE}" = 'aarch64' ]; then
MACHINE_IS_64BIT='yes'
fi
vim ./src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
return "arm";
case S390X:
return "s390x";
+ case AARCH64:
+ return "aarch64";
default:
return "unknown";
}
vim ./src/main/java/com/google/devtools/build/lib/util/CPU.java
X86_64("x86_64", ImmutableSet.of("amd64", "x86_64", "x64")),
PPC("ppc", ImmutableSet.of("ppc", "ppc64", "ppc64le")),
ARM("arm", ImmutableSet.of("arm", "armv7l")),
+ AARCH64("aarch64", ImmutableSet.of("aarch64")),
S390X("s390x", ImmutableSet.of("s390x", "s390")),
UNKNOWN("unknown", ImmutableSet.of()) ;
vim ./third_party/BUILD
+config_setting(
+ name = "aarch64",
+ values = {"host_cpu": "aarch64"},
+)
config_setting(
name = "freebsd",
values = {"host_cpu": "freebsd"},
)
vim ./tools/cpp/cc_configure.bzl
result = repository_ctx.execute(["uname", "-m"])
if result.stdout.strip() in ["power", "ppc64le", "ppc"]:
return "ppc"
- if result.stdout.strip() in ["arm", "armv7l", "aarch64"]:
+ if result.stdout.strip() in ["arm", "armv7l"]:
return "arm"
+ if result.stdout.strip() in ["aarch64"]:
+ return "aarch64"
return "k8" if result.stdout.strip() in ["amd64", "x86_64", "x64"] else "piii"
./compile
可能出现错误,java内存泄露问题,进入compile.sh中:
vim scripts/bootstrap/compile.sh
并且替换下面内容
- ${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}"
+ ${JAVAC}" -J-Xms256m -J-Xmx384m -classpath "${classpath}" -sourcepath "${sourcepath}"
最后运行compile
./compile
成功安装bazel 0.4.4。
当然,如果再以这种版本的bazel安装tensorflow1.0时候会出现一些错误,应为bazel在0.6版本左右的时候改变了下载验证的方式,所以之前的所做的工作都没什么卵用,但最终我安装了tensorflow1.5版本在nanopc T3 上,通过ARM64架构安装Tensorflow 这篇文章成功安装。
参考
Running Google Machine Learning Library Tensorflow On ARM 64-bit Platform
bazel compilejava.lang.OutOfMemoryErro