eaplatanios / tensorflow_scala

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

tensorflow_framework not found error on compile #26

Closed sbrunk closed 6 years ago

sbrunk commented 7 years ago

I finally had the time to have a look at your library again and I see you've made a lot of progress in the meantime!

I'm having a problem getting it to work on a new machine running OSX. I have installed libtensorflow 1.3.1 via homebrew. Now I'm getting the following error:

sbt:TensorFlow for Scala> compile
[info] Generating TensorFlow tensor op files.
[info] Building library with native build tool CMake.
[info] -- JNI include directories: /System/Library/Frameworks/JavaVM.framework/Headers;/System/Library/Frameworks/JavaVM.framework/Headers;/System/Library/Frameworks/JavaVM.framework/Headers
[error] CMake Error at CMakeLists.txt:32 (message):
[error]   Library `tensorflow_framework` not found.
[info] -- Configuring incomplete, errors occurred!
[info] See also "/Users/brunksn/repos/extern/tensorflow_scala/jni/target/native/darwin-x86_64/build/CMakeFiles/CMakeOutput.log".
[error] java.lang.RuntimeException: Failed to build the native library. Exit code: 1.
[error]         at scala.sys.package$.error(package.scala:27)
[error]         at BuildTool$ConfigureMakeInstall$Instance.libraries(BuildTool.scala:61)
[error]         at BuildTool$ConfigureMakeInstall$Instance.libraries$(BuildTool.scala:58)
[error]         at BuildTool$CMake$$anon$3.libraries(BuildTool.scala:113)
[error]         at JniNative$.$anonfun$settings$12(JniNative.scala:88)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:42)
[error]         at sbt.std.Transform$$anon$4.work(System.scala:64)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:257)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]         at sbt.Execute.work(Execute.scala:266)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:257)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:167)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:32)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] (jni/*:nativeCompile) Failed to build the native library. Exit code: 1.
[error] Total time: 1 s, completed 03.10.2017 08:38:39

I'm a bit at a loss about where tensorflow_framework is supposed to come from. Any ideas what I'm missing?

eaplatanios commented 7 years ago

@sbrunk Sorry about that. It's because I'm using the master branch of TensorFlow, rather than the 1.3 release. I'll push a big set of changes soon (probably some time tomorrow) that add support for control flow ops (i.e., cond and whileLoop) and fix lots of the current issues. I'm sorry for the inconvenience and the small delay.

eaplatanios commented 6 years ago

@sbrunk Could you please try again with the master branch? You can obtain the libtensorflow.so and libtensorflow_framework.so libraries by downloading extracting this jar file.

sbrunk commented 6 years ago

It finds the libraries but now I get the following error:

[info] [  4%] Building CXX object CMakeFiles/tensorflow_ops.dir/ops/jvm_callback_op.cc.o
[info] /Library/Developer/CommandLineTools/usr/bin/c++  -Dtensorflow_ops_EXPORTS -I/Users/brunksn/repos/extern/tensorflow_scala/jni/src/main/native/. -I/Users/brunksn/repos/extern/tensorflow_scala/jni/src/main/native/./generated -I/Users/brunksn/repos/extern/tensorflow_scala/jni/src/main/native/./include -I/Users/brunksn/repos/extern/tensorflow_scala/jni/src/main/native/./ops -I/System/Library/Frameworks/JavaVM.framework/Headers  -D_GLIBCXX_USE_CXX11_ABI=0 -O3 -DNDEBUG -fPIC   -std=gnu++11 -o CMakeFiles/tensorflow_ops.dir/ops/jvm_callback_op.cc.o -c /Users/brunksn/repos/extern/tensorflow_scala/jni/src/main/native/ops/jvm_callback_op.cc
[error] /Users/brunksn/repos/extern/tensorflow_scala/jni/src/main/native/ops/jvm_callback_op.cc:188:53: error: use of undeclared identifier 'JNI_VERSION_1_8'
[error]     int jvmEnvStatus = jvm_->GetEnv((void **) &env, JNI_VERSION_1_8);
[error]                                                     ^
[error] /Users/brunksn/repos/extern/tensorflow_scala/jni/src/main/native/ops/jvm_callback_op.cc:207:52: error: use of undeclared identifier 'JNI_VERSION_1_8'
[error]     int jvmEnvStatus = jvm_->GetEnv((void**) &env, JNI_VERSION_1_8);
[error]                                                    ^
[error] 2 errors generated.
[error] make[2]: *** [CMakeFiles/tensorflow_ops.dir/ops/jvm_callback_op.cc.o] Error 1
[error] make[1]: *** [CMakeFiles/tensorflow_ops.dir/all] Error 2
[error] make: *** [all] Error 2
eaplatanios commented 6 years ago

@sbrunk That's because the library required a newer version of JNI than the one you have. I pushed a small change that removes that requirement. Can you please check that it compiles fine now?

sbrunk commented 6 years ago

Working fine now :) Thanks for your help!

eaplatanios commented 6 years ago

I’m happy to hear that! Please, let me know if you find any other issues. :)

On Oct 14, 2017, 4:17 PM -0400, Sören Brunk notifications@github.com, wrote:

Working fine now :) Thanks for your help! — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

jS5t3r commented 6 years ago

@eaplatanios where do I find libtensorflow.so and libtensorflow_framework.so on my ubuntu?

sbrunk commented 6 years ago

@jS5t3r Have a look at the installation docs.

The easy way is to get the libraries is to download this jar (cpu / gpu) from sonatype and extract it. That's actually what happens automatically when you add the tensorflow dependency with the right classifier.

The other way, also decribed in the documentation, is to check out the tensorflow master branch and compile it yourself.

Just one suggestion: The gitter channel might be a better place to ask that kind of question instead of adding them to a closed issue. ;)