在Scala中使用DL4J,未找到后端

时间:2018-08-28 00:04:35

标签: sbt dl4j

我正在为dl4j编写一个简单的scala项目。我需要在cuda(用于培训)和本机用于生产之间切换。我在组装的jar中使用本机似乎有问题。我收到以下错误:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.datavec.api.util.ndarray.RecordConverter.toMinibatchArray(RecordConverter.java:197)
    at org.deeplearning4j.datasets.datavec.RecordReaderMultiDataSetIterator.next(RecordReaderMultiDataSetIterator.java:159)
    at org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator.next(RecordReaderDataSetIterator.java:364)
    at org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator.next(RecordReaderDataSetIterator.java:439)
    at simplecuda.main$.delayedEndpoint$simplecuda$main$1(main.scala:37)
    at simplecuda.main$delayedInit$body.apply(main.scala:27)
    at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
    at scala.App$class.main(App.scala:76)
    at simplecuda.main$.main(main.scala:27)
    at simplecuda.main.main(main.scala)
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:5449)
    at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:213)
    ... 15 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:213)
    at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5446)
    ... 16 more

我的构建文件是:

name := "simplecuda"
version := "1.0"
scalaVersion := "2.11.8"


// looks like you need to remove ~/.ivy2/cache and ~/.javacpp/cache whenever you switch between platforms 
classpathTypes += "maven-plugin"
libraryDependencies ++= Seq(
    "org.scalactic" %% "scalactic" % "3.0.5",
    "org.scalatest" %% "scalatest" % "3.0.5" % "test",

    // "org.nd4j" % "nd4j-cuda-9.2-platform" % "1.0.0-beta2",   
    // "org.deeplearning4j" % "deeplearning4j-cuda-9.2" % "1.0.0-beta2"

    "org.nd4j" % "nd4j-native-platform" % "1.0.0-beta2",
    "org.deeplearning4j" % "deeplearning4j-core" % "1.0.0-beta2"
)

assemblyMergeStrategy in assembly := {
    case PathList("META-INF", xs @ _*) => MergeStrategy.discard
    case x => MergeStrategy.first
}   

当我访问http://nd4j.org/getstarted.html来了解noAvailableBackendException时,我看到build.sbt应该有以下一行:

classpathTypes += "maven-plugin"

我已将其包含在上述build.sbt中,没有任何运气。在查看gradle指令后,我尝试添加"org.bytedeco.javacpp-presets" % "openblas" % "0.2.20-1.3" classifier "linux-x86_64"依赖项,但这也无济于事。

我尝试多次删除~/.javacpp/cache~/.ivy2/cache,但没有任何运气。此示例的存储库位于https://github.com/tomlue/dl4j_scala_troubleshoot

0 个答案:

没有答案