[英]tensorflow: “trying to mutate a frozen object”, bazel
MacOS high sierra, MBP 2016, in terminal. 终端中的MacOS High Sierra,MBP 2016。
I'm following the directions here: https://github.com/tensorflow/models/tree/master/research/syntaxnet All options for ./configure chosen as default (and all python directories double-checked.). 我遵循这里的指示: https : //github.com/tensorflow/models/tree/master/research/syntaxnet将./configure的所有选项都选择为默认选项(并仔细检查所有python目录。)。 All steps have completed cleanly until this: 所有步骤均已干净完成,直到:
bazel test ...
# On Mac, run the following:
bazel test --linkopt=-headerpad_max_install_names \
dragnn/... syntaxnet/... util/utf8/...
I assume I'm supposed to run the latter line ("bazel test --linkopt" etc.). 我假设我应该运行后一行(“ bazel测试--linkopt”等)。 But I get the same result either way, interestingly. 但是有趣的是,无论哪种方式我都得到相同的结果。
This throws about 10 errors, each of the same type "trying to mutate a frozen object", and concludes tests not run, error loading package dragnn/protos, and couldn't start build. 这将引发大约10个错误,每个错误的类型均相同,即“试图使冻结的对象发生变异”,并得出以下结论:测试未运行,错误加载包dragnn / protos且无法开始构建。
This is the general form of the errors: 这是错误的一般形式:
syntaxnet>> bazel test --linkopt=-headerpad_max_install_names dragnn/... syntaxnet/... util/utf8/... 语法网>> bazel测试--linkopt = -headerpad_max_install_names dragnn / ...语法网/ ... util / utf8 / ...
. 。
ERROR: /Users/XXX/Desktop/NLP/syntaxnet/models/research/syntaxnet/dragnn/protos/BUILD:35:1: Traceback (most recent call last): File "/Users/XXX/Desktop/NLP/syntaxnet/models/research/syntaxnet/dragnn/protos/BUILD", line 35 tf_proto_library_py(name = "data_py_pb2", srcs = ["dat..."]) File "/Users/XXX/Desktop/NLP/syntaxnet/models/research/syntaxnet/syntaxnet/syntaxnet.bzl", line 53, in tf_proto_library_py py_proto_library(name = name, srcs = srcs, srcs_versi...", <5 more arguments>) File "/private/var/tmp/_bazel_XXX/f74e5a21c3ad09aeb110d9de15110035/external/protobuf_archive/protobuf.bzl", line 374, in py_proto_library py_libs += [default_runtime] trying to mutate a frozen object ERROR: package contains errors: dragnn/protos 错误:/ Users / XXX / Desktop / NLP / syntaxnet / models / research / syntaxnet / dragnn / protos / BUILD:35:1:Traceback(最近一次通话):文件“ / Users / XXX / Desktop / NLP / syntaxnet / models / research / syntaxnet / dragnn / protos / BUILD“,第35行tf_proto_library_py(name =” data_py_pb2“,srcs = [” dat ...“])文件” / Users / XXX / Desktop / NLP / syntaxnet / models / research /syntaxnet/syntaxnet/syntaxnet.bzl“,第53行,在tf_proto_library_py py_proto_library(name = name,srcs = srcs,srcs_versi ...”,<5个其他参数>)文件“ / private / var / tmp / _bazel_XXX / f74e5a21a3109外部/protobuf_archive/protobuf.bzl“,第374行,在py_proto_library中py_libs + = [default_runtime]试图突变冻结的对象错误:程序包包含错误:dragnn / protos
... [same error for various 'name = "...pb2"' files] ... ... [各种'name =“ ... pb2”'文件的相同错误] ...
INFO: Elapsed time: 0.709s FAILED: Build did NOT complete successfully (17 packages loaded) ERROR: Couldn't start the build. 信息:经过的时间:0.709s失败:构建未成功完成(已加载17个软件包)错误:无法开始构建。 Unable to run tests 无法运行测试
Any idea what could be doing this? 知道该怎么做吗? Thanks. 谢谢。
This error indicates a bug in the py_proto_library
rule implementation. 此错误表明py_proto_library
规则实现中存在错误。
tf_proto_library_py
is defined in syntaxnet.bzl
. tf_proto_library_py
在syntaxnet.bzl
tf_proto_library_py
中定义。 It is a wrapper around py_proto_library
, which is defined by the tf_workspace
macro's protobuf_archive
rule. 它是py_proto_library
的包装,该包装由tf_workspace
宏的protobuf_archive
规则定义。
"protobuf_archive" downloads Protobuf 3.3.0, which contains //:protobuf.bzl
with the buggy py_proto_library
rule implementation: in line #374 it tries to mutate an immutable object py_libs
. “ protobuf_archive”将下载Protobuf 3.3.0,其中包含//:protobuf.bzl
和具有错误的py_proto_library
规则实现:在第374行中,它试图使不可变的对象py_libs
突变。
Make sure you use the latest Bazel version , currently that's 0.8.1. 确保使用最新的Bazel版本 ,当前版本为 0.8.1。
If the problem still persists, then: 如果问题仍然存在,则:
I suggest filing a bug with: 我建议通过以下方式提交错误:
py_proto_library
rule Protobuf,修复py_proto_library
规则 tf_workspace
, and TensorFlow,以在tf_workspace
更新其Protobuf版本,并 //research/syntaxnet
to the bugfixed version. 语法网将//research/syntaxnet
中的TF子模块引用更新为错误修复的版本。 As a workaround, perhaps you can patch protobuf.bzl
. 解决方法是,您可以修补protobuf.bzl
。
The patch is to change these lines: 补丁是要更改这些行:
373 if default_runtime and not default_runtime in py_libs + deps:
374 py_libs += [default_runtime]
375
376 native.py_library(
377 name=name,
378 srcs=outs+py_extra_srcs,
379 deps=py_libs+deps,
380 imports=includes,
381 **kargs)
to these: 这些:
373 if default_runtime and not default_runtime in py_libs + deps:
374 py_libs2 = py_libs + [default_runtime]
375 else:
376 py_libs2 = py_libs
377
378 native.py_library(
379 name=name,
380 srcs=outs+py_extra_srcs,
381 deps=py_libs2+deps,
382 imports=includes,
383 **kargs)
Disclaimer: this is a "blind" fix; 免责声明:这是“盲目”修复; I have not tried whether it works. 我没有尝试过是否有效。
Tried same pattern patch for cc_libs.
if default_runtime and not default_runtime in cc_libs:
cc_libs2 = cc_libs + [default_runtime]
else:
cc_libs2 = cc_libs
if use_grpc_plugin:
cc_libs += ["//external:grpc_lib"]
native.cc_library(
name=name,
srcs=gen_srcs,
hdrs=gen_hdrs,
deps=cc_libs2 + deps,
includes=includes,
**kargs)
Shows new error, but keeps compiling. 显示新错误,但仍在编译。 (Ubuntu 16 on Windows System for Linux--don't ask, native tensorflow 1.4 winx64 works, but not syntaxnet). (适用于Linux的Windows系统上的Ubuntu 16-不用问,本机tensorflow 1.4 winx64可以工作,但语法网不起作用)。
greg@FX11:/mnt/c/code/models/research/syntaxnet$ bazel test ... ERROR: /home/greg/.cache/bazel/_bazel_greg/adb8eb0eab8b9680449366fbebe59ec2/external/org_tensorflow/tensorflow/core/kernels/BUILD:451:1: in _transitive_hdrs rule @org_tensorflow//tensorflow/core/kernels:bounds_check_lib_gather: Traceback (most recent call last): File "/home/greg/.cache/bazel/_bazel_greg/adb8eb0eab8b9680449366fbebe59ec2/external/org_tensorflow/tensorflow/core/kernels/BUILD", line 451 _transitive_hdrs(name = 'bounds_check_lib_gather') File "/home/greg/.cache/bazel/_bazel_greg/adb8eb0eab8b9680449366fbebe59ec2/external/org_tensorflow/tensorflow/tensorflow.bzl", line 869, in _transitive_hdrs_impl set() greg @ FX11:/ mnt / c / code / models / research / syntaxnet $ bazel test ...错误:/home/greg/.cache/bazel/_bazel_greg/adb8eb0eab8b9680449366fbebe59ec2/external/org_tensorflow/tensorflow/core/kernels/BUILD: 451:1:在_transitive_hdrs规则中@ org_tensorflow // tensorflow / core / kernels:bounds_check_lib_gather:追溯(最近一次调用为最后):文件“ /home/greg/.cache/bazel/_bazel_greg/adb8eb0eab8b9680449366fbebe59ec2/core/org/tensorflow / kernels / BUILD“,第451行_transitive_hdrs(name ='bounds_check_lib_gather')File” /home/greg/.cache/bazel/_bazel_greg/adb8eb0eab8b9680449366fbebe59ec2/external/org_tensorflow/tensorflow/tensorflow/tensorflow.bzl“ )
Just changed set() to depset() and that seems to have avoided the error. 只是将set()更改为depset(),这似乎避免了该错误。
To make a long story short. 使长话短说。 I was inspired by a sstrasburg 's comment. 我受到sstrasburg的评论的启发。
Firstly, uninstall a fresh version of bazel. 首先,卸载新版本的bazel。
brew uninstall bazel
Download bazel 0.5.4 from here . 从此处下载bazel 0.5.4。
chmod +x bazel-0.5.4-without-jdk-installer-darwin-x86_64.sh
./bazel-0.5.4-without-jdk-installer-darwin-x86_64.sh
After that, again run 之后,再次运行
bazel test --linkopt=-headerpad_max_install_names dragnn/... syntaxnet/... util/utf8/...
Finally, I got 终于,我得到了
Executed 57 out of 57 tests: 57 tests pass. 在57个测试中执行了57个:57个测试通过。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.