OutOfMemoryError:Tensorflow上的Java堆空间测试执行

时间:2017-03-21 12:17:13

标签: java tensorflow bazel

使用命令执行Tensorflow测试套件:

bazel test //tensorflow/...

抛出内存不足问题:

INFO: Found 1886 targets and 1155 test targets...
INFO: Elapsed time: 291.775s, Critical Path: 0.91s
java.lang.OutOfMemoryError: Java heap space
        at com.google.devtools.build.skyframe.SkyKey.create(SkyKey.java:57)
        at com.google.devtools.build.lib.skyframe.ArtifactSkyKey.key(ArtifactSkyKey.java:43)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.toKeys(ActionExecutionFunction.java:576)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:158)
        at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:370)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:501)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Java heap space

bazel ran out of memory and crashed.

我试过以下选项仍然存在问题。

  

export _JAVA_OPTIONS =" -Xms1024m -Xmx1024m"

     

export JVM_ARGS =" -Xmx1024m -XX:MaxPermSize = 256m"

     

export JVM_ARGS =" -XX:PermSize = 64M -XX:MaxPermSize = 256m"

另外,从bazel代码更改了文件:scripts / bootstrap / compile.sh

" run "${JAVAC}" -J-Xms1g -J-Xmx1g -classpath "${classpath}" -sourcepath "${sourcepath}""

机器配置:Ubuntu发行版,openjdk8,RAM 16G

1 个答案:

答案 0 :(得分:1)

尝试使用正确的名称设置JAVA_OPTIONS并且不使用引号字符:

JAVA_OPTIONS= -Xms512m -Xmx1024m

如果它不起作用,可能不使用JAVA_OPTIONS env变量。
您可以尝试直接指定执行命令中的参数。 According to the official documentation,你可以这样做:

bazel test --host_jvm_args=-Xms512m --host_jvm_args=-Xmx1024m //tensorflow/...