Matt Murphy
Matt Murphy

Reputation: 11

Tensorflow build from source, cannot include contrib

I'm building TF from source and have no trouble including contrib in python. I get a segfault when I try to access this module with the following error:

error: _single_image_random_dot_stereograms.so debug map object file '/private/var/tmp/_bazel_mattmurphy/7ec540cd2482edb7e06749c20652a791/execroot/org_tensorflow/bazel-out/darwin-dbg/bin/tensorflow/contrib/image/_objs/python/ops/_single_image_random_dot_stereograms.so/tensorflow/contrib/image/kernels/single_image_random_dot_stereograms_ops.o' has changed (actual time is 2018-04-23 12:26:04.000000000, debug map time is 2018-04-21 20:47:03.000000000) since this executable was linked, file will be ignored
error: _single_image_random_dot_stereograms.so debug map object file '/private/var/tmp/_bazel_mattmurphy/7ec540cd2482edb7e06749c20652a791/execroot/org_tensorflow/bazel-out/darwin-dbg/bin/tensorflow/contrib/image/_objs/python/ops/_single_image_random_dot_stereograms.so/tensorflow/contrib/image/ops/single_image_random_dot_stereograms_ops.o' has changed (actual time is 2018-04-23 12:26:05.000000000, debug map time is 2018-04-21 20:47:02.000000000) since this executable was linked, file will be ignored
Process 58138 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x48)
    frame #0: 0x0000000131682290 _single_image_random_dot_stereograms.so`google::protobuf::internal::Mutex::Lock(this=0x0000000000000048) at common.cc:376
   373  }
   374
   375  void Mutex::Lock() {
-> 376    int result = pthread_mutex_lock(&mInternal->mutex);
   377    if (result != 0) {
   378      GOOGLE_LOG(FATAL) << "pthread_mutex_lock: " << strerror(result);
   379    }
Target 0: (python) stopped.

It looks like the issue is protobuf related, but this has been difficult to diagnose.

Upvotes: 1

Views: 276

Answers (1)

Till Brychcy
Till Brychcy

Reputation: 2924

I'm observing the same problem when compiling on MacOS 10.13.4 with Xcode 9.3.

The problem is that protobuf is statically linked into libtensorflow_framework.so, but also into _single_image_random_dot_stereograms.so and libforestprotos.so, which get loaded when contrib is imported.

Here a relevant protobuf issue.

A comment in that issue says that the problem appears when compiling with Xcode 8.3 or later, so I assume that the official tensorflow binary works, because it is built using an older version.

As workaround, I have locally removed the two occurences of "@protobuf_archive//:protobuf" in /tensorflow/tensorflow/tensorflow/contrib/image/BUILD and /tensorflow/tensorflow/tensorflow/contrib/tensor_forest/BUILD.

This doesn't seem to break anything for my use case of doing local experiments in python.

Upvotes: 1

Related Questions