gpt4 book ai didi

java - Deeplearning4j 示例不适用于 gradle

转载 作者:行者123 更新时间:2023-11-30 10:23:33 26 4
gpt4 key购买 nike

我正在尝试从 deeplearning4j 示例运行 CnnSentenceClassification。我将这个文件移到了我的 Gradle 项目中。当我从 eclipse 运行类(class)时,它工作正常。但是,当我从 ./gradlew run 运行它时,出现以下错误:

Exception in thread "main" java.lang.ExceptionInInitializerError
at
main.CnnSentenceClassification.main(CnnSentenceClassification.java:75)
Caused by: java.lang.RuntimeException:
org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException:
Please ensure that you have an nd4j backend on your classpath. Please
see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:6089)
at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:201)
... 1 more
Caused by:
org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException:
Please ensure that you have an nd4j backend on your classpath. Please
see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4jBackend.load(Nd4jBackend.java:258)
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:6086)
... 2 more

我检查过,nd4j-api-0.9.1.jar 在我的类路径中。这是我的 build.gradle:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'

repositories {
jcenter()
}

mainClassName="main.CnnSentenceClassification"

dependencies {
compile group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '0.9.1'
compile group: 'org.deeplearning4j', name: 'deeplearning4j-nlp', version: '0.9.1'

testCompile group: 'org.nd4j', name: 'nd4j-native-platform', version: '0.9.1'
compile group: 'org.nd4j', name: 'nd4j-api', version: '0.9.1'

compile "org.slf4j:slf4j-simple:1.7.25"
compile "org.slf4j:slf4j-api:1.7.25"
}

最佳答案

我遇到了同样的问题。您需要一个 ND4J 后端,这意味着更新您的依赖关系树。

对于 Maven 构建,将以下依赖项添加到项目的 pom 中:

<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native</artifactId>
<version>0.9.1</version>
</dependency>

对于 Gradle 构建,只需在依赖项中添加以下行:

compile "org.nd4j:nd4j-native:0.9.1"

native 后端使用 CPU 进行计算。支持 CUDA 的图形卡还有另一个依赖项。

我发现此链接很有帮助: DL4J Performance Debugging

关于java - Deeplearning4j 示例不适用于 gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46953999/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com