Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Adam Pocock
    @Craigacp
    It's also a little easier to operate on code snippets, as the gitter mobile client (at least on Android) is pretty poor at formatting (and threading for that matter).
    But it's up to you.
    Aish
    @aishfenton
    Makes sense. Moved them to there :)
    Adam Pocock
    @Craigacp
    :+1:
    Aish
    @aishfenton
    I think I have to have the message "approved" for it to show up. Will add stacktrace + sig under that
    Adam Pocock
    @Craigacp
    Ok, we should be able to do that for you, do you have a link?
    There's a little bit a of a bump at first to prevent easy spam attacks, but after the first couple of posts all that stuff should go away.
    Aish
    @aishfenton
    No, once I posted the message it disappeared into the ether. I assume someone on the admin side has to click approve, or something
    Adam Pocock
    @Craigacp
    Ok. Karl & I have some level of privileges as SIG leads, but the admins have more so they might have to click ok first.
    ^ discussion moved here
    Adam Pocock
    @Craigacp
    Cool, thanks.
    Sriram Kumar R
    @SRIRAMKARPAGAM
    Is there an easy way to create custom operations in Tensorflow java binding? Like being able to convert a custom java method as a tensor flow operation
    Karl Lessard
    @karllessard
    Hi @SRIRAMKARPAGAM , sorry for the delay, actually there are endpoints available for registering a Java kernel to TensorFlow but it is not being wrapped in TF Java yet nor anyone has tried it so far. I don’t know what kind of performances to expect with this setup.
    So to the question “is there an easy way”, I would say “no” but is there a way, I would say “maybe”. Here’s a starting point for investigating in that direction in case you are interested.
    Jakob Sultan Ericsson
    @jakeri
    I might have asked this before. :-)
    Do you have a release schedule?
    We are interested to know when there will be a TF Java release of TF 2.5.
    Adam Pocock
    @Craigacp
    I think we're going to skip straight to TF 2.6.0. we ran through the list of things to merge before 0.4.0 at the last meeting and it's relatively short.
    Jakob Sultan Ericsson
    @jakeri
    That also sounds good. :)
    raftaa
    @raftaa
    hi, one question concerning restricting GPU performance of TF: In Python we managed to restrict the GPU memory of our TF process to a certain amount of the GPU menory with: " tf.config.set_logical_device_configuration(gpu, [tf.config.LogicalDeviceConfiguration(memory_limit=8192)])". In Java we tried to use setPerProcessGpuMemoryFraction to restrict it to 50%. The configuration in java is implemented as follows:
    GPUOptions gpu = ConfigProto.getDefaultInstance().getGpuOptions().toBuilder().setPerProcessGpuMemoryFraction(0.5).setAllowGrowth(true).build();
    ConfigProto config = ConfigProto.newBuilder(ConfigProto.getDefaultInstance()).setLogDevicePlacement(true).mergeGpuOptions(gpu).build();
    However, it doesn't work and we get an exception: org.tensorflow.exceptions.TensorFlowException: 2 root error(s) found.
    (0) Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, [...]
    Adam Pocock
    @Craigacp
    Could you post the full error message in a github issue?
    raftaa
    @raftaa
    I just created tensorflow/java#383 concerning the issue I mentioned above
    Adam Pocock
    @Craigacp
    Ok thanks, we'll follow up there.
    raftaa
    @raftaa
    I just noticed that the GPU memory is allocated when loading a model with "SavedModelBundle.load(...)". The GPUOptions in the ConfigProto are used later when opening a session e.g. to classify an image (at least in our code). How is this meant to be done? How can I set the GPU options before loading a model?
    raftaa
    @raftaa
    Ahhh... okay, now it works. It just placed the code to load the model after creating a session with the gpu parameters.
    Adam Pocock
    @Craigacp
    You should be able to supply the ConfigProto to the SavedModelBundle loader which should do that directly. I'd missed the SavedModelBundle part of your issue.
    raftaa
    @raftaa
    Yes, I see: SavedModelBundle.loader(tensorflowModelPath).withConfigProto(configProto).. thanks a lot, Adam. Sorry for the dumb questions.
    Adam Pocock
    @Craigacp
    No worries, it's not got the best documentation.
    Michael Kilian
    @deluxeomat
    Hi folks, just a question, is there a way to attach the tensorflow logging output to my log4j file logger?
    In python, i was able to pass my "log handler" with "tf.get_logger().addHandler(logHandler)" to receive all log events into my file logger.
    Now I'm searching for a simular solution in Java to log all the Tensorflow events.
    Adam Pocock
    @Craigacp
    It's being worked on but needs fixes in the TensorFlow C API.
    Karl Lessard
    @karllessard
    Hi everyone, just to announce that the latest 0.4.0 snapshots are now based on TF 2.6.0. For those who want to try it, let us know how it goes, thanks!
    tanzhenyu
    @tanzhenyu
    Good to know ConcreteFunction is now supported! Is that executing the same code path as what a traditional session.run(..., {'StatefulPartitionedCall'}, ...) does?
    Ryan Nett
    @rnett
    Yeah, that's what it uses internally. Although statefulness is determined by what's in the function
    Hanns Holger Rutz
    @Sciss
    Hi there. is tensorflow-java the best way to work with tensorflow in Scala, or are there alternative projects that be better suited to have direct Scala bindings?
    Adam Pocock
    @Craigacp
    I think it's the only one under active development. This project (https://github.com/eaplatanios/tensorflow_scala) has Scala bindings to the C API directly, but hasn't been updated to track newer versions of TensorFlow and I'm not sure of it's status.
    Hanns Holger Rutz
    @Sciss
    Ok, thanks. I'll check out both.
    Anthony Platanios
    @eaplatanios
    Hi! I’m behind tf-scala referenced above. It’s true that I haven’t updated the library in a while because I don’t have much free time, but it does work with TF 2.4 currently and we are also using it in production, so it’s reasonably stable.
    Karl Lessard
    @karllessard
    On that @eaplatanios , do you think it could be interesting to « merge » tf-scala in tf-java so you won’t have to maintain a separate project by yourself? Are you aware of any important feature currently missing in tf-java, but present in tf-scala, that would enhance user experience for Scala developers?
    Hanns Holger Rutz
    @Sciss
    Thank you, it's good to hear that.
    Hanns Holger Rutz
    @Sciss

    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)
    Like a Java example showing simple cycle of training an ANN, then creating some predictions.
    Hanns Holger Rutz
    @Sciss
    Trying to work through this tutorial https://www.baeldung.com/tensorflow-java - but Tensor.create seems to no longer exist. How do you create a constant scalar in the current version?
    and there is a more type safe API than stringly typed opBuilder?
    Hanns Holger Rutz
    @Sciss
    Ok, getting the hang of it. Is this the idiomatic way?
    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")
    Adam Pocock
    @Craigacp
    The examples repo is here https://github.com/TensorFlow/java-models
    That tutorial is for the old 1
    1.x API. The tests in the TensorFlow Java repo are the most up to date way of doing things. Note at the moment there's an issue with gradient determinism when building models for training that causes incorrect outputs occasionally.
    We are working on a higher level API, but it's not all available yet