GPUOptions gpu = ConfigProto.getDefaultInstance().getGpuOptions().toBuilder().setPerProcessGpuMemoryFraction(0.5).setAllowGrowth(true).build();
ConfigProto config = ConfigProto.newBuilder(ConfigProto.getDefaultInstance()).setLogDevicePlacement(true).mergeGpuOptions(gpu).build();
HI there. Are there any self-contained example projects to look at? I'm trying this, using sbt 1.5.5:
lazy val deps = new {
val tensorflow = "0.3.3"
}
lazy val root = project.in(file("."))
.settings(
scalaVersion := "3.0.2",
libraryDependencies ++= Seq(
"org.tensorflow" % "tensorflow-core-api" % deps.tensorflow,
"org.tensorflow" % "tensorflow-core-api" % deps.tensorflow classifier "linux-x86_64-mkl",
"org.tensorflow" % "tensorflow-framework" % deps.tensorflow,
)
)
and
package de.sciss.tf
import org.tensorflow.EagerSession
object Test:
def main(args: Array[String]): Unit =
val input = Array(-10.0, -5.0, 0.0, 5.0, 10.0)
val options = EagerSession.options()
val session = EagerSession.initDefault(options)
println("Here")
session.close()
But running it just tells me something for JNI isn't working yet:
Warning: Could not load Loader: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path: [/usr/java/packages/lib, /usr/lib/x86_64-linux-gnu/jni, /lib/x86_64-linux-gnu, /usr/lib/x86_64-linux-gnu, /usr/lib/jni, /lib, /usr/lib]
Warning: Could not load Pointer: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path: [/usr/java/packages/lib, /usr/lib/x86_64-linux-gnu/jni, /lib/x86_64-linux-gnu, /usr/lib/x86_64-linux-gnu, /usr/lib/jni, /lib, /usr/lib]
Warning: Could not load BytePointer: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path: [/usr/java/packages/lib, /usr/lib/x86_64-linux-gnu/jni, /lib/x86_64-linux-gnu, /usr/lib/x86_64-linux-gnu, /usr/lib/jni, /lib, /usr/lib]
2021-10-03 16:07:13.749139: I external/org_tensorflow/tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-10-03 16:07:13.749982: I external/org_tensorflow/tensorflow/core/common_runtime/process_util.cc:146] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
Here
Exception in thread "main" java.lang.IllegalStateException: Default eager session cannot be closed
at org.tensorflow.EagerSession.close(EagerSession.java:261)
at de.sciss.tf.Test$.main(Test.scala:11)
at de.sciss.tf.Test.main(Test.scala)
Tensor.create
seems to no longer exist. How do you create a constant scalar in the current version?
opBuilder
?
val g = new Graph()
val ops = Ops.create(g)
import ops.*
val a = constant(3.0)
val b = constant(2.0)
val x = placeholder(classOf[TFloat64])
val y = placeholder(classOf[TFloat64])
val ax = math.mul(a, x)
val by = math.mul(b, y)
val z = math.add(ax, by)
val session = new Session(g)
val r = session.runner()
val tensor = r.fetch(z)
.feed(x, TFloat64.scalarOf(3.0))
.feed(y, TFloat64.scalarOf(6.0))
.run
.get(0)
tensor match
case tf: TFloat64 => println(tf.getDouble()) // 21.0
case other => println(s"OTHER: $other")