2

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

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

4

0 回答 0