*** update - I think my problem described below is the same as this really recent post - No such method error when init model on snapshot ***
Hello everyone…seeking some help/advice. When using an LSTM model with CPU backend the program works. However when I switch to using GPUs I get the following error at runtime:
14:21:54.133 [examples.engine1.CudaTest.main()] INFO org.nd4j.linalg.jcublas.JCublasBackend - ND4J CUDA build version: 11.2.152
14:21:54.135 [examples.engine1.CudaTest.main()] INFO org.nd4j.linalg.jcublas.JCublasBackend - CUDA device 0: [GeForce RTX 3090]; cc: [8.6]; Total memory: [25447170048]
14:21:54.135 [examples.engine1.CudaTest.main()] INFO org.nd4j.linalg.jcublas.JCublasBackend - CUDA device 1: [GeForce RTX 3090]; cc: [8.6]; Total memory: [25447170048]
14:21:54.135 [examples.engine1.CudaTest.main()] INFO org.nd4j.linalg.jcublas.JCublasBackend - Backend build information:
GCC: “7.5.0”
STD version: 201402L
CUDA: 11.2.152
DEFAULT_ENGINE: samediff::ENGINE_CUDA
HAVE_FLATBUFFERS
14:21:56.401 [examples.engine1.CudaTest.main()] INFO org.deeplearning4j.nn.graph.ComputationGraph - Starting ComputationGraph with WorkspaceModes set to [training: ENABLED; inference: ENABLED], cacheMode set to [NONE]
14:21:56.420 [examples.engine1.CudaTest.main()] ERROR org.deeplearning4j.common.config.DL4JClassLoading - Cannot create instance of class ‘org.deeplearning4j.cuda.recurrent.CudnnLSTMHelper’.
java.lang.NoSuchMethodException: org.deeplearning4j.cuda.recurrent.CudnnLSTMHelper.(java.lang.Class, org.nd4j.linalg.api.buffer.DataType)
at java.base/java.lang.Class.getConstructor0(Class.java:3349)
at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2553)
at org.deeplearning4j.common.config.DL4JClassLoading.createNewInstance(DL4JClassLoading.java:103)
at org.deeplearning4j.common.config.DL4JClassLoading.createNewInstance(DL4JClassLoading.java:89)
at org.deeplearning4j.common.config.DL4JClassLoading.createNewInstance(DL4JClassLoading.java:74)
at org.deeplearning4j.nn.layers.HelperUtils.createHelper(HelperUtils.java:58)
at org.deeplearning4j.nn.layers.recurrent.LSTM.initializeHelper(LSTM.java:56)
at org.deeplearning4j.nn.layers.recurrent.LSTM.(LSTM.java:52)
at org.deeplearning4j.nn.conf.layers.LSTM.instantiate(LSTM.java:78)
at org.deeplearning4j.nn.conf.graph.LayerVertex.instantiate(LayerVertex.java:106)
at org.deeplearning4j.nn.graph.ComputationGraph.init(ComputationGraph.java:572)
at org.deeplearning4j.nn.graph.ComputationGraph.init(ComputationGraph.java:437)
my POM looks like:
4.0.0
<!-- Group-ID, artifact ID and version of the project. You can modify these as you want -->
<groupId>Reviewer.ly</groupId>
<artifactId>Reviewer.ly-MatchMaker</artifactId>
<version>0.5</version>
snapshots-repo
https://oss.sonatype.org/content/repositories/snapshots
false
true
daily
<!-- Properties Section. Change ND4J versions here, if required -->
<properties>
<dl4j-master.version>1.0.0-SNAPSHOT</dl4j-master.version>
<logback.version>1.2.3</logback.version>
<java.version>1.8</java.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- deeplearning4j-core: contains main functionality and neural networks -->
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-nlp</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-cuda-11.2-platform</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-cuda-11.2</artifactId>
<version>${dl4j-master.version}</version>
</dependency>
As I mentioned it works find with CPU backend. Looks like an LSTMHelper constructor is missing?
java.lang.NoSuchMethodException: org.deeplearning4j.cuda.recurrent.CudnnLSTMHelper.(java.lang.Class, org.nd4j.linalg.api.buffer.DataType)
???
The source code I am executing:
public class Seq2SeqATTN
{
public static int contextV_size = peer.NN.Settings.contextV_size;
public static double learningRate = 0.0001;
public static ComputationGraph nn_init()
{
ComputationGraphConfiguration config = new NeuralNetConfiguration.Builder()
.weightInit(WeightInit.XAVIER)
.updater(new Adam(learningRate))
// .l2(0.000001)
// .dropOut(85)
.graphBuilder()
// .allowDisconnected(true)
.addInputs(“inputEnc”, “inputDec”)
.addLayer("LSTMA", new LSTM.Builder()
// .activation(Activation.SWISH)
.nIn( Word2VecNeuralNetwork.layer_size )
.nOut( contextV_size )
.build(), “inputEnc”)
.addLayer("ATTN", new SelfAttentionLayer.Builder()
.nHeads(1)
.build(), "LSTMA")
.addVertex("THOUGHTAF", new LastTimeStepVertex("inputEnc"), "ATTN")
.addVertex("COPY", new DuplicateToTimeSeriesVertex("inputDec"), "THOUGHTAF")
.addVertex("CONTEXT", new MergeVertex(), "inputDec","COPY")
.addLayer("LSTMB", new LSTM.Builder()
// .activation(Activation.SWISH)
.nIn( contextV_size + Word2VecNeuralNetwork.layer_size )
.nOut( contextV_size )
.build(), “CONTEXT”)
.addLayer("output", new RnnOutputLayer.Builder(LossFunctions.LossFunction.MSE)
.activation( Activation.IDENTITY )
.nIn(contextV_size)
.nOut(Word2VecNeuralNetwork.layer_size)
.build(), "LSTMB")
.setOutputs("output")
// .backpropType(BackpropType.TruncatedBPTT)
// .tBPTTLength(20)
.build();
ComputationGraph net = new ComputationGraph(config);
net.init();
return net;
}
}
txs!