tensorflow / tensorflow/java

ivy dependency not working on windows or linux, native TF code not found on classpath

オープン
#496 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Java
スター
928
フォーク
227
PR マージ指標
30日以内にマージされた PR はありません

説明

Please make sure that this is a build/installation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04 x86_64): Linux Ubuntu 23.04_ x86_64
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version: 0.4.2
  • Java version (i.e., the output of java -version): 1.8.1
  • Java command line flags (e.g., GC parameters):
  • Installed from Maven Central?: Yes, via ivy
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:

Describe the problem
I'm trying to use tensorflow 2 with ivy.xml in java project. The problem is that the maven download is not complete. It only downloads either 1. no native platform, or 2. if I specify 2 platforms (windows and linux), it only downloads one of them. AND 3. when I manually download the relevant jars, it cannot find the native hooks.

Provide the exact sequence of commands / steps that you executed before running into the problem
I first tried ivy using these dependencies in various combinations, each time making sure to delete existing tensorflow jars from my ivy local cache folder:

    <dependency org="org.tensorflow" name="tensorflow-core-api" rev="0.4.2" m:classifier="linux-x86_64-gpu"/>
    <dependency org="org.tensorflow" name="tensorflow-core-api" rev="0.4.2" m:classifier="windows-x86_64-gpu"/>
    <dependency org="org.tensorflow" name="tensorflow-core-api" rev="0.4.2"/>

Since this did not work (I never got the full set of native jars), I downloaded the jars and put them in my local project jars folder, which is on the classpath.
jars/tensorflow-core-api-0.4.2.jar
jars/tensorflow-core-api-0.4.2-linux-x86_64-gpu.jar
jars/tensorflow-core-api-0.4.2-windows-x86_64-gpu.jar

These jars are added to the project classpath in netbeans 8.2 project dialog

Any other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

Here is the log output:

WARNING: java.lang.NoClassDefFoundError: java.lang.ClassNotFoundException: org.tensorflow.internal.c_api
    at org.bytedeco.javacpp.Loader.load(Loader.java:918)
    at org.bytedeco.javacpp.Loader.load(Loader.java:870)
    at org.tensorflow.NativeLibrary.load(NativeLibrary.java:48)
    at org.tensorflow.TensorFlow.<clinit>(TensorFlow.java:156)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.tensorflow.SavedModelBundle.<clinit>(SavedModelBundle.java:651)
    at net.sf.jaer.eventprocessing.filter.MLPNoiseFilter.loadNetwork(MLPNoiseFilter.java:720)
    at net.sf.jaer.eventprocessing.filter.MLPNoiseFilter.initFilter(MLPNoiseFilter.java:550)
    at net.sf.jaer.eventprocessing.filter.NoiseTesterFilter.initFilter(NoiseTesterFilter.java:1073)
    at net.sf.jaer.eventprocessing.FilterChain.initFilters(FilterChain.java:454)
    at net.sf.jaer.graphics.AEViewer.setChip(AEViewer.java:5863)
    at net.sf.jaer.graphics.AEViewer.constructChip(AEViewer.java:1020)
    at net.sf.jaer.graphics.AEViewer.setAeChipClass(AEViewer.java:928)
    at net.sf.jaer.graphics.AEViewer.<init>(AEViewer.java:520)
    at net.sf.jaer.JAERViewer$RunningThread.run(JAERViewer.java:231)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: org.tensorflow.internal.c_api
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.bytedeco.javacpp.Loader.load(Loader.java:913)
    ... 29 more

Here is the screenshot showing contents of the linux native jar:

Screenshot from 2023-06-12 16-34-54

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Ivy の依存関係宣言と、一覧にある 3 つの TensorFlow 0.4.2 jars から始め、org.tensorflow.NativeLibrary.load から org.bytedeco.javacpp.Loader.load までスタックトレースを追ってください。プラットフォーム固有のネイティブアーティファクトがクラスパス上に org.tensorflow.internal.c_api を公開しない理由を確認してください。報告されたプラットフォームで必要なネイティブ依存関係が解決され、SavedModelBundle の初期化で ClassNotFoundException が発生しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
build-system
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。