1

I am trying to install tensorflow using Maven, and run the code:

System.out.println(TensorFlow.version());

but the following error occurs:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot find TensorFlow native library for OS: windows, architecture: x86. See https://github.com/tensorflow/tensorflow/tree/master/java/README.md for possible solutions (such as building the library from source).
at org.tensorflow.NativeLibrary.load(NativeLibrary.java:66)
at org.tensorflow.TensorFlow.init(TensorFlow.java:27)
at org.tensorflow.TensorFlow.<clinit>(TensorFlow.java:31)
at ai.advance.project.App.main(App.java:12)


its look like java could not find the native library, even though I believe maven installed all the necessary jars and libraries (e.g. .dll).

my maven pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>ai.advance</groupId>
  <artifactId>project</artifactId>
  <version>1.0-SNAPSHOT</version>
     <properties>
       <exec.mainClass>HelloTF</exec.mainClass>
       <!-- The sample code requires at least JDK 1.7. -->
       <!-- The maven compiler plugin defaults to a lower version -->
       <maven.compiler.source>1.7</maven.compiler.source>
       <maven.compiler.target>1.7</maven.compiler.target>
     </properties>
     <dependencies>
       <dependency>
         <groupId>org.tensorflow</groupId>
         <artifactId>tensorflow</artifactId>
         <version>1.1.0</version>
       </dependency>
     </dependencies>
 </project>

NOTE: I am using eclipse IDE.

Khazam Alhamdan
  • 98
  • 2
  • 10
  • I think you need to install TensorFlow on your system. See [here](https://www.tensorflow.org/api_docs/java/reference/org/tensorflow/package-summary). Maven dependencies gets you the required libraries from the repository – Master Po May 07 '17 at 11:11
  • How are you running the program? Using `mvn compile exec:java` or something else? – ash May 09 '17 at 16:39
  • [check this answer](https://stackoverflow.com/questions/42350009/) it would be helpful ~! – Anshul Verma Jul 10 '17 at 23:59

1 Answers1

2

I had the same error and solved it by installing JDK 1.7 (64 bit) and switching the project's JRE to that in Eclipse. Previously i was using JDK 1.7 but the 32 bit version. I suppose that if Python 64 bit is installed / required by Tensorflow, a 64 bit JDK must be used as well.

David
  • 109
  • 2
  • 9