2017-05-07 69 views
1

我试图安装tensorflow使用Maven本地库,并运行代码:
TensorFlow找不到

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

但出现以下错误:

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) 


它看起来像java无法找到本地库,即使我相信maven安装了所有必需的jar和库(例如, G。 .DLL)。

我的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> 

注:我使用的Eclipse IDE中。

+0

我认为你需要在你的系统上安装TensorFlow。见[这里](https://www.tensorflow.org/api_docs/java/reference/org/tensorflow/package-summary)。 Maven依赖关系从存储库中获取所需的库 –

+0

如何运行该程序?使用'mvn compile exec:java'或其他东西? – ash

+0

[检查此答案](https://stackoverflow.com/questions/42350009/)它会有所帮助〜! –

回答

1

我有相同的错误,并通过安装JDK 1.7(64位)并将项目的JRE切换到Eclipse中来解决。以前我使用的是JDK 1.7,但使用32位版本。我想如果Tensorflow安装/需要Python 64位,则还必须使用64位JDK。

相关问题