eaplatanios / tensorflow_scala

TensorFlow API for the Scala Programming Language
http://platanios.org/tensorflow_scala/
Apache License 2.0
936 stars 96 forks source link

Exception in compiled from source application #113

Closed nazarblch closed 6 years ago

nazarblch commented 6 years ago

2018-06-14 14:54:20.444 [main] INFO Examples / Linear Regression - Building linear regression model. Exception in thread "main" java.lang.ExceptionInInitializerError at org.platanios.tensorflow.jni.Graph$.(Graph.scala:22) at org.platanios.tensorflow.jni.Graph$.(Graph.scala) at org.platanios.tensorflow.api.core.Graph$.apply(Graph.scala:843) at org.platanios.tensorflow.api.core.package$.(package.scala:26) at org.platanios.tensorflow.api.core.package$.(package.scala) at org.platanios.tensorflow.api.ops.package$.(package.scala:42) at org.platanios.tensorflow.api.ops.package$.(package.scala) at org.platanios.tensorflow.api.ops.Op$Builder.(Op.scala:1350) at org.platanios.tensorflow.api.ops.Basic.placeholder(Basic.scala:215) at org.platanios.tensorflow.api.ops.Basic.placeholder$(Basic.scala:214) at org.platanios.tensorflow.api.package$tf$.placeholder(package.scala:177) at org.platanios.tensorflow.examples.LinearRegression$.main(LinearRegression.scala:37) at org.platanios.tensorflow.examples.LinearRegression.main(LinearRegression.scala) Caused by: org.platanios.tensorflow.jni.NotFoundException: /tmp/tensorflow_scala_native_libraries661864839076572457/libtensorflow_ops.so: undefined symbol: _ZN10tensorflow14DataTypeStringENS_8DataTypeE at org.platanios.tensorflow.jni.TensorFlow$.loadOpLibrary(Native Method) at org.platanios.tensorflow.jni.TensorFlow$.$anonfun$load$6(TensorFlow.scala:114) at scala.Option.foreach(Option.scala:257) at org.platanios.tensorflow.jni.TensorFlow$.load(TensorFlow.scala:114) at org.platanios.tensorflow.jni.TensorFlow$.(TensorFlow.scala:162) at org.platanios.tensorflow.jni.TensorFlow$.(TensorFlow.scala)

eaplatanios commented 6 years ago

@nazarblch Could you please try using version 0.2.1. There was an issue that should hopefully have been fixed by now.

eaplatanios commented 6 years ago

I'll close this. Please move any discussion about issues with the precompiled binaries to #114. Thanks!

DirkToewe commented 6 years ago

I'm getting the exact same error on tensorflow_scala 0.2.2 when building Tensorflow myself:

undefined symbol: _ZN10tensorflow14DataTypeStringENS_8DataTypeE

Steps to Reproduce:

  1. git checkout r1.9
  2. ./configure with jemalloc, xla, latest llvm
  3. build libtensorflow_framework.so and libtensorflow.so (--config=opt --config=mkl)
  4. Run sbt with a project that loads the shared objects using System.load

My experience with C/C++ compilation is somewhat limited. Could it be that there is a compatibilty issue because the libtensorflow_jni.so was compiled with another compiler (version)? Is there a way of preventing tensorflow_scala from loading its own libtensorflow_jni.so?

eaplatanios commented 6 years ago

@DirkToewe Could you try compiling with this flag also passed to Bazel --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0?

As for compiling your own libtensorflow_jni.so, you can do that if you only depend on "org.platanios" %% "tensorflow-api" % "0.2.2" instead of the full combined package. In this case you'd need to compile the JNI package on your own and publish it locally.

However, I think that trying to use the flag I mentioned might help resolve this and it'd be easier. It's also likely to be added to the default TF flags because it is used by the C API anyway.

Please let me know if that works for you. :)

DirkToewe commented 6 years ago

-D_GLIBCXX_USE_CXX11_ABI=0 did do the trick. Thank You!