Подтвердить что ты не робот

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

Ответ 1

Похоже, что у вас нет файла nd4j backend, указанного в вашем файле pom. У вас должен быть один, и вы должны использовать только один (не используйте сразу несколько бэкендов в вашем помпе, если вы не используете профили). В настоящее время для версии 0.4-rc3.8 мне повезло с nd4j-x86 на Mac, Windows и Linux-устройствах, не поддерживающих GPU, Если у вас есть доступ к графическим процессорам, вы можете использовать один из nd4j-jcublas-7.x, но имейте в виду, что существует main Cuda переписать в соответствии с их Gitter.

Пока что

  • Прочитайте раздел "Зависимости и бэкэнд" http://deeplearning4j.org/quickstart.html,
  • Определите, какой бэкэнд подходит для вас в http://nd4j.org/dependencies.html (обратите внимание, что Jblas доступен только в том случае, если вы переходите к версии 0.4-rc3. 6)
  • Следите за dl4j Gitter
  • Если вы пытаетесь использовать графические процессоры, как я, следите за проблемой Github # 555

Вот как я настраивал свои зависимости 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>