1.按教程:bazel build -c opt --jobs 1 //tensorflow/cc:tutorials_example_trainer
出现
INFO: Reading options for 'build' from /opt/tensorflow/tools/bazel.rc:
'build' options: --force_python=py2 --host_force_python=py2 --python2_path=/usr/bin/python --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --define PYTHON_BIN_PATH=/usr/bin/python --spawn_strategy=standalone --genrule_strategy=standalone
Unrecognized option: --host_force_python=py2
网上找到解决方案:
It sounds like the Bazel you're using doesn't know about the --host_force_python
flag. The flag wasadded in January, is it possible you're using an old version of Bazel? You can check with bazel version
, make sure you're using at least 0.1.4 (optimally you'd be using 0.3.0).
Alternatively, you could just open up /home/ubuntu/tensorflow/tensorflow/tools/bazel.rc
and remove the line build --host_force_python=py2
, but I don't know how necessary that line is (so that might cause other problems).
2.再次输入:bazel build -c opt --jobs 1 //tensorflow/cc:tutorials_example_trainer
ERROR: /home/samuelchin/tensorflow/tensorflow/models/embedding/BUILD:10:6: First argument of load() is a path, not a label. It should start with a single slash if it is an absolute path.ERROR: /home/samuelchin/tensorflow/tensorflow/models/embedding/BUILD:10:6: file '/tensorflow:tensorflow.bzl.bzl' was not correctly loaded. Make sure the 'load' statement appears in the global scope in your file.
ERROR: /home/samuelchin/tensorflow/tensorflow/models/embedding/BUILD:104:1: name 'tf_gen_op_wrapper_py' is not defined.
ERROR: /home/samuelchin/tensorflow/tensorflow/tools/pip_package/BUILD:13:1: Target '//tensorflow/models/embedding:package' contains an error and its package is in error and referenced by '//tensorflow/tools/pip_package:build_pip_package'.
ERROR: Loading failed; build aborted.
INFO: Elapsed time: 0.071s.
网上找到答案:
There was a recent change to the TensorFlow BUILD
files that causes the dependency on Bazel 0.1.4. This was announced on the discuss@tensorflow.org
mailing list, but hasn't made it into the documentation on the website yet.
As you have already discovered, upgrading Bazel to version 0.1.4 should fix this build error.
查看bazel版本,果然版本不够高
Build label: 0.1.1
Build target: bazel-out/local_linux-fastbuild/bin/src/main/java/bazel-main_deploy.jar
Build time: Thu Oct 15 20:15:14 2015 (1444940114)
Build timestamp: 1444940114
Build timestamp as int: 1444940114
更新bazel版本:
$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$ curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install bazel
sudo apt-get upgrade bazel
或者直接去下载安装器:https://github.com/bazelbuild/bazel/releases总算可以了~
3.g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
主要原因大体上是因为内存不足,有点坑 ,虚拟机分配了1G内存,加内存到2G