Vamshi
December 15, 2022, 2:47pm
1
I am geting below java runtime error while loading a keras model
V [libjvm.dylib+0x584935] jni_SetLongField+0xc5
C [libjnihdf5.dylib+0x8196] Java_org_bytedeco_hdf5_Attribute_read__Lorg_bytedeco_hdf5_DataType_2Lorg_bytedeco_javacpp_BytePointer_2+0x2a6
j org.bytedeco.hdf5.Attribute.read(Lorg/bytedeco/hdf5/DataType;Lorg/bytedeco/javacpp/BytePointer;)V+0
j org.deeplearning4j.nn.modelimport.keras.Hdf5Archive.readAttributeAsString(Lorg/bytedeco/hdf5/Attribute;)Ljava/lang/String;+42
j org.deeplearning4j.nn.modelimport.keras.Hdf5Archive.readAttributeAsString(Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/String;+62
j org.deeplearning4j.nn.modelimport.keras.utils.KerasModelUtils.importWeights(Lorg/deeplearning4j/nn/modelimport/keras/Hdf5Archive;Ljava/lang/String;Ljava/util/Map;ILjava/lang/String;)V+270
j org.deeplearning4j.nn.modelimport.keras.KerasModel.<init>(Ljava/lang/String;Ljava/lang/String;Lorg/deeplearning4j/nn/modelimport/keras/Hdf5Archive;Ljava/lang/String;Ljava/lang/String;Lorg/deeplearning4j/nn/modelimport/keras/Hdf5Archive;Z[ILorg/deeplearning4j/nn/modelimport/keras/KerasLayer$DimOrder;)V+638
j org.deeplearning4j.nn.modelimport.keras.KerasModel.<init>(Lorg/deeplearning4j/nn/modelimport/keras/utils/KerasModelBuilder;)V+37
j org.deeplearning4j.nn.modelimport.keras.utils.KerasModelBuilder.buildModel()Lorg/deeplearning4j/nn/modelimport/keras/KerasModel;+5
j org.deeplearning4j.nn.modelimport.keras.KerasModelImport.importKerasModelAndWeights(Ljava/lang/String;Z)Lorg/deeplearning4j/nn/graph/ComputationGraph;+18
j wdnn_maven.wdnn_test.keras_test.main([Ljava/lang/String;)V+25
I am using deeplearning4j 1.0.0-M2.1 on mac m1
Can anyone help me understand whats the issue here
treo
December 15, 2022, 2:56pm
2
That looks like a stacktrace out of a JVM crash file. Put that file on gist.github.com and link that gist here.
Whatever you are doing seems to result in a JVM crash while reading your HDF5 file.
Vamshi
December 15, 2022, 3:18pm
3
Hi @treo
Please find the attached link
gistfile1.txt
package wdnn_maven.wdnn_test;
import java.io.*;
import org.deeplearning4j.nn.modelimport.keras.KerasModelImport;
import org.deeplearning4j.nn.modelimport.keras.exceptions.InvalidKerasConfigurationException;
import org.deeplearning4j.nn.modelimport.keras.exceptions.UnsupportedKerasConfigurationException;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
import org.deeplearning4j.nn.graph.ComputationGraph;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.Nd4j;
import org.datavec.api.util.ClassPathResource;
This file has been truncated. show original
gistfile2.txt
package wdnn_maven.wdnn_test;
import java.util.HashMap;
import java.util.Map;
import org.deeplearning4j.nn.api.layers.LayerConstraint;
import org.deeplearning4j.nn.conf.InputPreProcessor;
import org.deeplearning4j.nn.conf.inputs.InputType;
import org.deeplearning4j.nn.conf.layers.DenseLayer;
import org.deeplearning4j.nn.conf.layers.BaseLayer;
import org.deeplearning4j.nn.modelimport.keras.KerasLayer;
This file has been truncated. show original
treo
December 15, 2022, 3:36pm
4
Well, I’m not a compiler, so I’m not going to read all that code.
I asked for the jvm crash file, it should be called something like hs_err_pid<pid>.log
where <pid>
is some number.
treo
December 15, 2022, 4:11pm
6
So you are using it in emulated x64 mode. I wonder if something about that may be the issue, as it is very unusual to see a segmentation fault at that particular place.
@agibsonccc what do you think?
@treo I think this might be a data type overflow when hdf5 is reading the file. @Vamshi could you please DM me your model? I’d like to look at this. There’s only so much I can do but I can at least inspect what’s going on with the model file.
I recently saw a similar error importing a model on my Mac (failed on both an Intel and Silicon one) with error at:
V [libjvm.dylib+0x584935] jni_SetLongField+0xc5
The error went away when I removed BatchNormalization from the first layer of model.
I can try to regenerate and upload model if that would be helpful
@bjohnson yes that would be amazing thank you!
nas-sh
June 8, 2023, 3:49pm
10
@treo @agibsonccc I am getting the same java runtime error as the one posted here by Vamshi. Were you able to find out what the problem is and how to resolve it?
nas-sh
June 8, 2023, 5:25pm
11
@Vamshi could you find out what the problem was? I am experiencing a similar issue.
@nas-sh same question: do you have something I can see to reproduce this?
nas-sh
June 9, 2023, 10:57pm
13
@agibsonccc you should be able to reproduce the error by importing our h5 file here . Would you like to see the model in python also?
On Java side, I use the following to import the h5 model which leads to the error in the native code:
KerasModelImport.importKerasModelAndWeights(h5ModelPath, false);