org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException

org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException

我不知道它想从我这里得到什么。我正在使用

    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-core</artifactId>
        <version>${deeplearning4j.version}</version>
    </dependency>

    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-nlp</artifactId>
        <version>${deeplearning4j.version}</version>
    </dependency>

其中

<deeplearning4j.version>0.4-rc3.8</deeplearning4j.version>

但我得到了

Caused by: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: null
    at org.nd4j.linalg.factory.Nd4jBackend.load(Nd4jBackend.java:148) ~[nd4j-api-0.4-rc3.7.jar:na]
    at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:4498) ~[nd4j-api-0.4-rc3.7.jar:na]
    ... 53 common frames omitted

如果我尝试加载 Google 词向量模型:

@RequestMapping("/loadModel")
public Boolean loadModel(@RequestParam(value="model") String model) {

    Resource resource = appContext.getResource("WEB-INF/word-vector-models/" + model);

    try {
        File modelFile = resource.getFile();

        System.err.println(modelFile.getAbsolutePath());
        WordVectors googleModel = WordVectorSerializer.loadGoogleModel(modelFile, true);
        this.wordVectorsMap.put(model, googleModel);
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }

    return true;
}

您似乎没有 nd4j backend specified in your pom file. You have to have one, and you should use only one (don't have multiple backends in your pom at once unless you use profiles). Currently, for version 0.4-rc3.8, I've had luck with nd4j-x86 on non-GPU enabled Mac, Windows and linux boxes. If you have access to GPUs, you could use one of the nd4j-jcublas-7.x jars, but be aware that there is a major Cuda rewrite going on according to their Gitter

目前,

以下是我设置 pom.xml 依赖项的方法。默认情况下((即 mvn clean install),它与 nd4j-x86 一起运行,但是当我将我的代码拉到 GPU 盒子上时,我只需附加配置文件名称(因此 mvn clean install -P cuda)并轻松切换后端:

<!-- Platform-dependent backend selection (netlib is default) -->
<profiles>
    <profile>
        <id>cuda</id>
        <dependencies>
            <dependency>
                <groupId>org.nd4j</groupId>
                <artifactId>nd4j-jcublas-${cuda.version}</artifactId>
                <version>${nd4j.version}</version>
            </dependency>
        </dependencies>
    </profile>
    <profile>
        <id>netlib</id>
        <dependencies>
            <dependency>
                <groupId>org.nd4j</groupId>
                <artifactId>nd4j-x86</artifactId>
                <version>${nd4j.version}</version>
            </dependency>
        </dependencies>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
</profiles>
<!-- end platform-dependent backend selection -->


<dependencies>
<!-- dl4j dependencies -->
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-core</artifactId>
        <version>${dl4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-ui</artifactId>
        <version>${dl4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-scaleout-api</artifactId>
        <version>${dl4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-scaleout-akka</artifactId>
        <version>${dl4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-scaleout-zookeeper</artifactId>
        <version>${dl4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-nlp</artifactId>
        <version>${dl4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-aws</artifactId>
        <version>${dl4j.version}</version>
    </dependency>
    <!-- end dl4j dependencies -->

    <!-- nd4j dependencies -->
    <dependency>
        <groupId>org.nd4j</groupId>
        <artifactId>canova-nd4j-image</artifactId>
        <version>${canova.version}</version>
    </dependency>
    <dependency>
        <groupId>org.nd4j</groupId>
        <artifactId>canova-nd4j-codec</artifactId>
        <version>${canova.version}</version>
    </dependency>
    <!-- end nd4j dependencies -->

    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-yaml</artifactId>
        <version>${jackson.version}</version>
    </dependency>

    <dependency>
        <groupId>net.java.openjfx.backport</groupId>
        <artifactId>openjfx-78-backport</artifactId>
        <version>1.8.0-ea-b96.1</version>
    </dependency>


    <!-- logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.13</version>
    </dependency>
    <!-- end logging -->


    <dependency>
        <groupId>org.apache.maven.reporting</groupId>
        <artifactId>maven-reporting-api</artifactId>
        <version>2.2.1</version>
    </dependency>
</dependencies>