lhelontra / tensorflow-on-arm

TensorFlow for Arm
MIT License
1.05k stars 274 forks source link

Failed to build bazel on VMware mechine with 2GB RAM #20

Closed liuqun closed 6 years ago

liuqun commented 6 years ago

The following bash code doesn't work when I try to build bazel-0.10.0 with only 2GB RAM or less: https://github.com/lhelontra/tensorflow-on-arm/blob/7ca59b4ddc1dc33e2a35fa22a8d176b9c3f2f73c/build_tensorflow/build_tensorflow.sh#L106-L112

Output is:

Building Bazel from scratch../usr/lib/jvm/java-8-openjdk-amd64/bin/javac -classpath third_party/gson/gson-2.2.4.jar:third_party/plexus_utils/plexus-utils-3.0.21.jar:third_party/hazelcast/hazelcast-client-3.6.4.jar:third_party/hazelcast/hazelcast-3.6.4.jar:third_party/.......
...
The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: GC overhead limit exceeded
    at com.sun.tools.javac.code.Types.freshTypeVariables(Types.java:4120)
    at com.sun.tools.javac.code.Types.capture(Types.java:4068)
    at com.sun.tools.javac.comp.Infer$InferenceContext.cachedCapture(Infer.java:2318)
    at com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1014)
    at com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:835)
    at com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:735)
    at com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:844)
    at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:162)
    at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:567)
    at com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:604)
    at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3829)
    at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3616)
    at com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3527)
    at com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3502)
    at com.sun.tools.javac.comp.Attr.checkId(Attr.java:3489)
    at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3371)
    at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
    at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
    at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1825)
    at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
    at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
    at com.sun.tools.javac.comp.DeferredAttr$2.complete(DeferredAttr.java:285)
    at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:246)
    at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:233)
    at com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1008)
    at com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:835)
    at com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:735)
    at com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:844)
    at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:579)
    at com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:604)
    at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3829)
    at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3616)
chmod: cannot access 'output/bazel': No such file or directory
mv: cannot stat 'output/bazel': No such file or directory

Here is my patch code:

lhelontra commented 6 years ago

uses swapfile for solves this problem. For example:

# fallocate -l 4G swap.img && mkswap swap.img && swapon swap.img
# sysctl vm.swappiness=70
liuqun commented 6 years ago

Thanks. I just add the RAM to 3GB to my VMware machine. Seems that 3GB RAM works for me.

By the way when I ran the build script inside a docker container, there was no swap space available by default. (Even if the docker host does have a 4GB sized hard disk swap partition)