tensorflow / java

Java bindings for TensorFlow
Apache License 2.0
831 stars 202 forks source link

Trying to build version 1.0.0-rc.1 module org.tensorflow can no longer be found. #553

Closed odinsbane closed 3 months ago

odinsbane commented 3 months ago

System information

When I tried to upgrade to 1.0.0.rc-1 I get src/main/java/module-info.java:[4,17] module not found: org.tensorflow

Provide the exact sequence of commands / steps that you executed before running into the problem

I have a working pom.xml with the dependency.

    <dependency>
      <groupId>org.tensorflow</groupId>
      <artifactId>tensorflow-core-platform-gpu</artifactId>
      <version>0.5.0</version>
    </dependency>

I wanted to switch to the 1.0.0 release candidate by following the github page.

<dependency>
  <groupId>org.tensorflow</groupId>
  <artifactId>tensorflow-core-api</artifactId>
  <version>1.0.0-rc.1</version>
</dependency>
<dependency>
  <groupId>org.tensorflow</groupId>
  <artifactId>tensorflow-core-native</artifactId>
  <version>1.0.0-rc.1</version>
  <classifier>linux-x86_64</classifier>
</dependency>

Then my module-info.java causes an error and the project doesn't compile.

src/main/java/module-info.java:[4,17] module not found: org.tensorflow

I could setup a complete source code + pom.xml to reproduce the problem. Maybe this problem is simpler than that though, and I am using the wrong dependencies.

karllessard commented 3 months ago

Hi @odinsbane , starting from tensorflow java 1.0.0-rc1, the module has been renamed to simply tensorflow

https://github.com/tensorflow/java/blob/9a62e687b0d8c07c36d5fe7a6e54c4ac83856853/tensorflow-core/tensorflow-core-api/src/main/java/module-info.java#L17

karllessard commented 3 months ago

Which makes me realize that this indication is missing in our migration instructions, I’ll make sure to add this as well, thank you

odinsbane commented 3 months ago

That did it, I changed the requires then everything built and even ran successfully.

odinsbane commented 3 months ago

@karllessard Something else that might be good to explain. Instead of using the artifact-id to denote the GPU version. Now it uses the "tensorflow-core-natives" with <classifier>linux-x86_64-gpu</classifier> to get the gpu natives. I didn't find the distinction until I went through the maven repos a bit.

karllessard commented 3 months ago

@odinsbane that part is mentioned in the migrating guide though, please look at this section: https://github.com/tensorflow/java/blob/master/MIGRATING.md#native-artifact-renaming

odinsbane commented 3 months ago

@karllessard I was specifically referring to the tensorflow-core-platform-gpu artifact which no longer exists. The 0.5.0 example seems a little strange because it has the same artifactId twice, but one has an identifier.

<dependency>
    <groupId>org.tensorflow</groupId>
    <artifactId>tensorflow-core-api</artifactId>
    <version>0.5.0</version>
</dependency>
<dependency>
    <groupId>org.tensorflow</groupId>
    <artifactId>tensorflow-core-api</artifactId>
    <version>0.5.0</version>
    <classifier>linux-x86_64</classifier>
</dependency>

The way I did it used the <artifactId>tensorflow-core-platform-gpu</artifactId>. Maybe it is clear, and I don't understand how the maven classifiers work well enough.

Craigacp commented 3 months ago

The platform artifact pulls in a set of native libraries (currently Windows x86_64, Linux x86_64, macOS x86_64 and macOS arm64), and the platform gpu artifact used to pull in both Linux & Windows GPU binaries until Google stopped supporting Windows GPU binaries. When that happened we stopped making a platform-gpu artifact because it was identical to depending on org.tensorflow:tensorflow-core-native:1.0.0-rc.1:linux-x86_64-gpu.