Ubuntu18安装bazel而后bazel build

我以前安装的bazel是根据官方推荐的最后一种方法(Using Bazel's APT repository)来的,但其实我仅仅是用了几句,由于其余行代码彻底无效。人家说了jdk的安装是可选择的。html

curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -

sudo apt-get update && sudo apt-get install bazel

sudo apt-get install --only-upgrade bazel

安装后我依旧在tensorflow-master文件夹下bazel build,此次终于出现了昨天的情景,特么的我换个服务器了,卧槽,效果就是不同。没有备用的服务器就只能下载、卸载、下载、卸载。python

tensorflow-master$ bazel build tensorflow/lite/toco:toco

Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=107
INFO: Reading rc options for 'build' from /..../tensorflow-master/.bazelrc:
  'build' options: --apple_platform_type=macos --define framework_shared_object=true --define open_source_build=true --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone --strategy=Genrule=standalone -c opt --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 --announce_rc --define=grpc_no_ares=true --define=PREFIX=/usr --define=LIBDIR=$(PREFIX)/lib --define=INCLUDEDIR=$(PREFIX)/include
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-toolchains/archive/92dd8a7a518a2fb7ba992d47c8b38299fe0be825.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
INFO: Call stack for the definition of repository 'io_bazel_rules_docker' which is a git_repository (rule definition at /home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git.bzl:195:18):
 - /home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_toolchains/repositories/repositories.bzl:37:9
 - /../tensorflow-master/WORKSPACE:35:1
ERROR: An error occurred during the fetch of repository 'io_bazel_rules_docker':
   Traceback (most recent call last):
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git.bzl", line 177
		_clone_or_update(ctx)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git.bzl", line 36, in _clone_or_update
		git_repo(ctx, directory)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 91, in git_repo
		_update(ctx, git_repo)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 103, in _update
		fetch(ctx, git_repo)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 129, in fetch
		_git_maybe_shallow(ctx, git_repo, "fetch", "origin", <2 more arguments>)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 171, in _git_maybe_shallow
		_error(ctx.name, (start + args_list), st.st...)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 181, in _error
		fail(("error running '%s' while worki...)))
error running 'git fetch origin refs/heads/*:refs/remotes/origin/* refs/tags/*:refs/tags/*' while working with @io_bazel_rules_docker:
Timed out
ERROR: no such package '@io_bazel_rules_docker//repositories': Traceback (most recent call last):
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git.bzl", line 177
		_clone_or_update(ctx)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git.bzl", line 36, in _clone_or_update
		git_repo(ctx, directory)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 91, in git_repo
		_update(ctx, git_repo)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 103, in _update
		fetch(ctx, git_repo)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 129, in fetch
		_git_maybe_shallow(ctx, git_repo, "fetch", "origin", <2 more arguments>)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 171, in _git_maybe_shallow
		_error(ctx.name, (start + args_list), st.st...)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 181, in _error
		fail(("error running '%s' while worki...)))
error running 'git fetch origin refs/heads/*:refs/remotes/origin/* refs/tags/*:refs/tags/*' while working with @io_bazel_rules_docker:
Timed out
ERROR: no such package '@io_bazel_rules_docker//repositories': Traceback (most recent call last):
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git.bzl", line 177
		_clone_or_update(ctx)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git.bzl", line 36, in _clone_or_update
		git_repo(ctx, directory)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 91, in git_repo
		_update(ctx, git_repo)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 103, in _update
		fetch(ctx, git_repo)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 129, in fetch
		_git_maybe_shallow(ctx, git_repo, "fetch", "origin", <2 more arguments>)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 171, in _git_maybe_shallow
		_error(ctx.name, (start + args_list), st.st...)
	File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 181, in _error
		fail(("error running '%s' while worki...)))
error running 'git fetch origin refs/heads/*:refs/remotes/origin/* refs/tags/*:refs/tags/*' while working with @io_bazel_rules_docker:
Timed out
INFO: Elapsed time: 1054.854s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

奇怪的是此次居然能够用自动补全功能(tensorflow/lite),以前是彻底不行的,也就是说以前的bazel安装可能有问题。linux

可是此次仍旧以失败了结,我特么想死了。c++

一直从bazelbuild的github下载什么东西:https://github.com/bazelbuild/rules_docker 不明因此啊。git

卸载另外一个服务器的bazel,从新安装,手动捂脸。刚下载了darwin版本的bazel感受不对劲,又换成了linux版本的,好吧,这是我用的推荐的第一种方法安装bazelgithub

sudo apt autoremove bazel
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python3

而后从bazel的github官方下载sh:bazel-0.29.1-installer-linux-x86_64.sh           这是我下的版本docker

chmod +x bazel-0.29.1-installer-linux-x86_64.sh

而后我就懵逼了,让我带--user ,我特么不带这玩意也不知道对不对,反正我都试了。带这玩意后告诉我一堆东西,我都yesshell

./bazel-0.29.1-installer-linux-x86_64.sh --user
Uncompressing../home/./.bazel/bin/_bazel:  write error (disk full?).  Continue? (y/n/^C) y

/home/./.bazel/bin/bazel:  write error (disk full?).  Continue? (y/n/^C) y

/home/./.bazel/bin/bazel-complete.bash:  write error (disk full?).  Continue? (y/n/^C) y
/home/./.bazel/bin/bazel-complete.bash  bad CRC d73dc8f3  (should be 7978f2a5)
/home/./.bazel/bin/bazel-real:  write error (disk full?).  Continue? (y/n/^C) y
/home/./.bazel/bin/bazel-real  bad CRC 4bb4f452  (should be 80f0b082)

#/./ is instead of my name

谁知道这个错误咋该啊?难道我内存不足??当初用Ubuntu就是由于环境好设置,这倒好了,让我设置这些玩意,我去尼玛的。macos

free -m还有不少free啊,这是为什么?json

一样的代码,不一样服务器效果不一样,卧槽。

bazel build tensorflow/lite/toco:toco

后来发现不行,cuda和cudnn必须升级才能升级tf,目前能安装且成功运行的就是tf1.12.0,我暂时无能为力了。

官方给出了bazel tf gcc 相对应的版本:https://tensorflow.google.cn/install/source
可是我在另外一个服务器

tensorflow-master$ bazel build tensorflow/lite/toco:toco


INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=107
INFO: Reading rc options for 'build' from /./tensorflow-master/.bazelrc:
  'build' options: --apple_platform_type=macos --define framework_shared_object=true --define open_source_build=true --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone --strategy=Genrule=standalone -c opt --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 --announce_rc --define=grpc_no_ares=true --define=PREFIX=/usr --define=LIBDIR=$(PREFIX)/lib --define=INCLUDEDIR=$(PREFIX)/include
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-toolchains/archive/92dd8a7a518a2fb7ba992d47c8b38299fe0be825.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
DEBUG: Rule 'io_bazel_rules_docker' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1556410077 -0400"
DEBUG: Call stack for the definition of repository 'io_bazel_rules_docker' which is a git_repository (rule definition at /home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_tools/tools/build_defs/repo/git.bzl:195:18):
 - /home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/bazel_toolchains/repositories/repositories.bzl:37:9
 - /./tensorflow-master/WORKSPACE:35:1
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/protocolbuffers/protobuf/archive/310ba5ee72661c081129eb878c1bbcec936b20f0.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
Traceback (most recent call last):
  File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in <module>
    from builtins import bytes  # pylint: disable=redefined-builtin
ImportError: No module named builtins
INFO: Call stack for the definition of repository 'local_config_git' which is a git_configure (rule definition at /data/rnnoise/src/data/mss/pb2tflite/tensorflow-master/third_party/git/git_configure.bzl:63:17):
 - /./tensorflow-master/tensorflow/workspace.bzl:74:5
 - /./tensorflow-master/WORKSPACE:19:1
ERROR: An error occurred during the fetch of repository 'local_config_git':
   Traceback (most recent call last):
	File "/./tensorflow-master/third_party/git/git_configure.bzl", line 61
		_fail(result.stderr)
	File "/./tensorflow-master/third_party/git/git_configure.bzl", line 14, in _fail
		fail(("%sGit Configuration Error:%s %...)))
Git Configuration Error: Traceback (most recent call last):
  File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in <module>
    from builtins import bytes  # pylint: disable=redefined-builtin
ImportError: No module named builtins

INFO: Call stack for the definition of repository 'gemmlowp' which is a tf_http_archive (rule definition at /./tensorflow-master/third_party/repo.bzl:121:19):
 - /./tensorflow-master/tensorflow/workspace.bzl:239:5
 - /./tensorflow-master/WORKSPACE:19:1
INFO: Repository 'gemmlowp' used the following cache hits instead of downloading the corresponding file.
 * Hash '6678b484d929f2d0d3229d8ac4e3b815a950c86bb9f17851471d143f6d4f7834' for https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/gemmlowp/archive/12fed0cd7cfcd9e169bf1925bc3a7a58725fdcc3.zip
If the definition of 'gemmlowp' was updated, verify that the hashes were also updated.
INFO: Call stack for the definition of repository 'fft2d' which is a tf_http_archive (rule definition at /./tensorflow-master/third_party/repo.bzl:121:19):
 - /./tensorflow-master/tensorflow/workspace.bzl:605:5
 - /./tensorflow-master/WORKSPACE:19:1
INFO: Call stack for the definition of repository 'zlib_archive' which is a tf_http_archive (rule definition at /./tensorflow-master/third_party/repo.bzl:121:19):
 - /./tensorflow-master/tensorflow/workspace.bzl:593:5
 - /./tensorflow-master/WORKSPACE:19:1
ERROR: /./tensorflow-master/tensorflow/core/BUILD:2741:1: //tensorflow/core:version_info_gen depends on @local_config_git//:gen/spec.json in repository @local_config_git which failed to fetch. no such package '@local_config_git//': Traceback (most recent call last):
	File "/./tensorflow-master/third_party/git/git_configure.bzl", line 61
		_fail(result.stderr)
	File "/./tensorflow-master/third_party/git/git_configure.bzl", line 14, in _fail
		fail(("%sGit Configuration Error:%s %...)))
Git Configuration Error: Traceback (most recent call last):
  File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in <module>
    from builtins import bytes  # pylint: disable=redefined-builtin
ImportError: No module named builtins

ERROR: /./tensorflow-master/tensorflow/core/BUILD:2741:1: //tensorflow/core:version_info_gen depends on @local_config_git//:gen/head in repository @local_config_git which failed to fetch. no such package '@local_config_git//': Traceback (most recent call last):
	File "/./tensorflow-master/third_party/git/git_configure.bzl", line 61
		_fail(result.stderr)
	File "/./tensorflow-master/third_party/git/git_configure.bzl", line 14, in _fail
		fail(("%sGit Configuration Error:%s %...)))
Git Configuration Error: Traceback (most recent call last):
  File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in <module>
    from builtins import bytes  # pylint: disable=redefined-builtin
ImportError: No module named builtins

ERROR: /./tensorflow-master/tensorflow/core/BUILD:2741:1: //tensorflow/core:version_info_gen depends on @local_config_git//:gen/branch_ref in repository @local_config_git which failed to fetch. no such package '@local_config_git//': Traceback (most recent call last):
	File "/./tensorflow-master/third_party/git/git_configure.bzl", line 61
		_fail(result.stderr)
	File "/./tensorflow-master/third_party/git/git_configure.bzl", line 14, in _fail
		fail(("%sGit Configuration Error:%s %...)))
Git Configuration Error: Traceback (most recent call last):
  File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in <module>
    from builtins import bytes  # pylint: disable=redefined-builtin
ImportError: No module named builtins

WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-cpp/archive/43ef2148c0936ebf7cb4be6b19927a9d9d145b8f.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
ERROR: Analysis of target '//tensorflow/lite/toco:toco' failed; build aborted: no such package '@local_config_git//': Traceback (most recent call last):
	File "/./tensorflow-master/third_party/git/git_configure.bzl", line 61
		_fail(result.stderr)
	File "/./tensorflow-master/third_party/git/git_configure.bzl", line 14, in _fail
		fail(("%sGit Configuration Error:%s %...)))
Git Configuration Error: Traceback (most recent call last):
  File "/home/./.cache/bazel/_bazel_xulm1/b172144b72497b6793e5891257276c30/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in <module>
    from builtins import bytes  # pylint: disable=redefined-builtin
ImportError: No module named builtins

INFO: Elapsed time: 0.588s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 0 targets configured)

一些路径被我用/./替代了,都是我的服务器文件地址,没用。告诉我没有builtins,怎么可能?我在python3下是能够import的啊

不过发现python2下的确没有这个玩意,难道bazel build编译是用的py2 ??那么能指定版本不???

其实自己python2/3环境都已经有bytes了不知道为啥还要import,难道不同?所以我将这一行注释了。

终于在众多WARNING中成功编译了:bazel build tensorflow/lite/toco:toco 这一步成功了。结果以下:

Target //tensorflow/lite/toco:toco up-to-date:
  bazel-bin/tensorflow/lite/toco/toco
INFO: Elapsed time: 319.744s, Critical Path: 82.86s
INFO: 2427 processes: 2427 local.
INFO: Build completed successfully, 2460 total actions

可是我下一步bazel-bin出错了,卧槽。人生艰难啊。

tensorflow-master$ bazel-bin/tensorflow/lite/toco/toco 
--graph_def_file=../my_freeze12xshell.pb --output_file=../my12.tflite 
--output_format=TFLITE --input_shape=2,4,513 --input_array=x_mixed 
--output_array=y_out1,y_out2 --inference_type=QUANTIZED_UINT8 
--inference_input_type=QUANTIZED_UINT8 --std_dev_values=1 --mean_values=0

2019-09-19 16:07:25.290293: F tensorflow/lite/toco/model_cmdline_flags.cc:236] Check failed: !(uses_single_input_flags && uses_multi_input_flags) 
Use either the singular-form input flags (--input_array, --input_shape, --mean_value, --std_value) 
or the plural form input flags (--input_arrays, --input_shapes, --mean_values, --std_values), 
but not both forms within the same command line.
Aborted (core dumped)

这是啥错误信息啊?一脸懵逼。

 

另外有相关问题能够加入QQ群讨论,不设微信群

QQ群:868373192 

语音深度学习及信号处理群