Modular Java app can't create tensor object
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 28/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- java
研究方向
先從 src/main/java/module-info.java 和 build.gradle 開始,然後檢查涉及 IllegalAccessException 的 TensorFlow Java 模組宣告。透過 com.varankin.ocrc.Inferencer.image 以及 TInt32/TFloat32 張量建立呼叫重現此故障。當模組化 Gradle 應用程式能夠建立張量,且不再出現所回報的存取警告時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): YES
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04 x86_64): Windows 10 Pro
- TensorFlow installed from (source or binary): Gradle dependence
- TensorFlow version (use command below): 2.10.1
- Java version (i.e., the output of
java -version): 17.0.2 - Java command line flags (e.g., GC parameters):
- Python version (if transferring a model trained in Python):
- Bazel version (if compiling from source):
- GCC/Compiler version (if compiling from source):
- CUDA/cuDNN version: 12.3
- GPU model and memory:
Describe the current behavior
Java Gradle project, as built from IntelliJ IDEA pattern, repeatedly reports a fatal warning on attempt to create a tensor object. See the code and log below. The error raises exception that is effectively intercepted by JavaFX runtime.
The project was found having Java module support. After this support has been removed from the project, code runs just fine. However, modularity is highly desired for the application.
Describe the expected behavior
After module access permissions (exports, open's) get fixed in tensorflow-core-platform, etc., all Java objects should be created just fine, as they are in non-modular edition of the project.
Code to reproduce the issue
excerpt from file src/main/java/module-info.java:
module com.varankin.ocrc.jfx
{
requires org.tensorflow.ndarray;
requires org.tensorflow;
}
excerpt from file build.gradle (remove shown lines to let code run with no error):
plugins
{
id 'org.javamodularity.moduleplugin' version '1.8.12'
}
dependencies
{
implementation 'org.tensorflow:tensorflow-core-platform:0.5.0'
}
excerpt from file src/main/java/com/varankin/ocrc:
package com.varankin.ocrc;
import org.tensorflow.*;
import org.tensorflow.ndarray.*;
import org.tensorflow.types.TFloat32;
import org.tensorflow.types.TInt32;
public class Inferencer
{
public void image( float[][] data )
{
FloatNdArray data_nda = NdArrays.ofFloats( Shape.of( data.length, data[0].length ) );
data_nda.elements( /* 0, */ 1 ).forEachIndexed( (ix,nda) -> nda.setFloat( data[(int)ix[0]][(int)ix[1]] ) );
// OK before this line; any next line fails;
TInt32 tdata_is = TInt32.scalarOf( 24 );
TInt32 tdata_i = TInt32.tensorOf( Shape.of( 24, 24 ) );
TFloat32 tdata_0 = TFloat32.tensorOf( Shape.of( 24, 24 ) );
tdata_0.set( data_nda );
TFloat32 tdata = TFloat32.tensorOf( data_nda );
}
}
Other info / logs
Warning: Could not create an instance of class org.tensorflow.internal.c_api.presets.tensorflow: java.lang.IllegalAccessException: class org.bytedeco.javacpp.ClassProperties (in module org.bytedeco.javacpp) cannot access class org.tensorflow.internal.c_api.presets.tensorflow (in module org.tensorflow) because module org.tensorflow does not export org.tensorflow.internal.c_api.presets to module org.bytedeco.javacpp
Call stack has been wiped off by JavaFX, below is manual reproduction
- com.varankin.ocrc.Inferencer.image
- org.tensorflow.types.TInt32.scalarOf:44 -- same for TFloat32 methods
- org.tensorflow.Tensor.of:128
- org.tensorflow.RawTensor.allocate:109
Please do not hesitate to ask for runnable example if needed. Current project cannot be presented as-is because of IP protection requirements, and because it's bulky.
- 主要語言
- Java
- 星號
- 928
- 分支
- 227
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
tensorflow/java 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 65/100
tensorflow/java#653 · 1 則留言 · 4 個 reaction ·
-
難度 5/5 一週以上 新手友好度 25/100
tensorflow/java#621 · 4 則留言 ·
-
難度 5/5 一週以上 新手友好度 25/100
tensorflow/java#617 · 3 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 55/100
tensorflow/java#615 · 1 則留言 ·
-
難度 5/5 一週以上 新手友好度 25/100
tensorflow/java#614 · 1 則留言 ·
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
infinispan/infinispan#18150 ·
-
難度 2/5 1-3 小時 新手友好度 84/100
-
untriaged
難度 2/5 1-3 小時 新手友好度 82/100
opensearch-project/k-NN#3597 ·
-
bug
難度 2/5 1-3 小時 新手友好度 88/100
-
bug
難度 2/5 1-3 小時 新手友好度 82/100