# LSTMHelper error with GPU backend

**URL:** <https://community.konduit.ai/t/lstmhelper-error-with-gpu-backend/1399>\
**Category:** DL4J\
**Created:** [May 22, 2021, 6:38pm UTC](https://community.konduit.ai/t/lstmhelper-error-with-gpu-backend/1399 "2021-05-22T18:38:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcuzzola](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jcuzzola](https://community.konduit.ai/u/jcuzzola)\
**Post date:** [May 22, 2021, 6:38pm UTC](https://community.konduit.ai/t/lstmhelper-error-with-gpu-backend/1399/1 "2021-05-22T18:38:23Z")

</div>

\*\*\* update - I think my problem described below is the same as this really recent post - [No such method error when init model on snapshot](https://community.konduit.ai/t/no-such-method-error-when-init-model-on-snapshot/1395/5) \*\*\*

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!

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [May 22, 2021, 11:08pm UTC](https://community.konduit.ai/t/lstmhelper-error-with-gpu-backend/1399/2 "2021-05-22T23:08:53Z")

</div>

@jcuzzola yes I can confirm the issue here and just explained it as well:

> [@No such method error when init model on snapshot](https://community.konduit.ai/t/no-such-method-error-when-init-model-on-snapshot/1395/6):
>
> @MPdaedalus thanks. Yeah that’s fine. My suggestion did workfor another user and should keep your setup running, but I understand the hesitation in wanting to deal with cloning the code base. The main issue atm is I’m simultaneously doing release testing + the need to do manual snapshots atm. Ideally this whole process would be automated, but with github actions quotas, they kill your jobs if you run too many at once. This is on top of sonatype purging snapshots every 3 days or so. I’ll work o…

This will go away with the release and we’ll have something more sustainable after. Sorry this was due to a CI migration to GH actions. There were a few bumps to sort out, but an upgrade was needed in order for us to release more consistently. You have the option of doing what I suggested in the post as a workaround. In the mean time I kicked off a few snapshot builds for both linux and windows cuda 11.0 and 11.2. You’re welcome to try later, install from source following my instructions, or wait till the release.

---

<div class="post-metadata">

**Author:** ![jcuzzola](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jcuzzola](https://community.konduit.ai/u/jcuzzola)\
**Post date:** [May 23, 2021, 12:48am UTC](https://community.konduit.ai/t/lstmhelper-error-with-gpu-backend/1399/3 "2021-05-23T00:48:22Z")

</div>

> [@agibsonccc](#):
>
> You’re welcome to try later, install from source following my instructions

\*\*\* txs for the quick response! … your instructions for install from source worked for me. cheers!
