我不知道我想要什么。我在用
<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单词 vector 模型:
@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;
}
最佳答案
看来您的pom文件中没有指定nd4j backend。您必须拥有一个,并且只能使用一个(除非您使用配置文件,否则pom中不能一次拥有多个后端)。目前,对于0.4-rc3.8版本,我在未启用GPU的Mac,Windows和linux机器上拥有nd4j-x86的运气。如果您可以使用GPU,则可以使用nd4j-jcublas-7.x个jar之一,但是请注意,根据major Cuda rewrite,有一个Gitter正在运行。
目前,
这是我设置pom.xml依赖项的方法。默认情况下((即
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>