12

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

    <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;
}
4

1 回答 1

20

看起来您的 pom 文件中没有指定nd4j后端。你必须有一个,而且你应该只使用一个(不要在你的 pom 中同时有多个后端,除非你使用配置文件)。目前,对于 0.4-rc3.8 版本,我在非 GPU 启用的 Mac、Windows 和 linux 机器上使用nd4j-x86很幸运。如果您可以访问 GPU,则可以使用nd4j-jcublas-7.x jar 之一,但请注意,根据他们的Gitter正在进行重大的 Cuda 重写

目前,

这是我设置 pom.xml 依赖项的方式。默认情况下 ((ie mvn clean install),它使用 nd4j-x86 运行,但是当我将代码拉到 GPU 盒上时,我只需附加配置文件名称 (so 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>
于 2016-02-19T20:57:29.927 回答