# Required libraries to run tensorflow on Windows

**URL:** <https://discuss.ai.google.dev/t/required-libraries-to-run-tensorflow-on-windows/31996>\
**Category:** JVM\
**Tags:** library, windows\
**Created:** [July 21, 2023, 11:04am UTC](https://discuss.ai.google.dev/t/required-libraries-to-run-tensorflow-on-windows/31996 "2023-07-21T11:04:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Richard](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@Robert\_Richard](https://discuss.ai.google.dev/u/Robert_Richard)\
**Post date:** [July 21, 2023, 11:04am UTC](https://discuss.ai.google.dev/t/required-libraries-to-run-tensorflow-on-windows/31996/1 "2023-07-21T11:04:46Z")

</div>

Hello everyone!

When run libtensorflow-2.7.0.jar, via cmd on a Windows 7 Pro x64 system, I get this error:

> E:\libtensorflow\>javac -cp libtensorflow-2.7.0.jar HelloTF.java  
> E:\libtensorflow\>java -cp libtensorflow-2.7.0.jar;. -Dorg.tensorflow.NativeLibrary.DEBUG=1 -Djava.library.path=“E:\libtensorflow” HelloTF

 ![libtensorflow270](https://d3qe71uytubmmx.cloudfront.net/original/2X/3/38c84333487fcf1433b59257939a9e82dcfd3486.jpeg)

When testing the “libtensorflow-1.4.0.jar” library, there are no errors:

> E:\libtensorflow\>javac -cp libtensorflow-1.4.0.jar HelloTF.java  
> E:\libtensorflow\>java -cp libtensorflow-1.4.0.jar;. -Dorg.tensorflow.NativeLibrary.DEBUG=1 -Djava.library.path=“E:\libtensorflow” HelloTF

 ![libtensorflow140](https://d3qe71uytubmmx.cloudfront.net/original/2X/a/ace7d94bd897e934d542393a4550ab93e3bb6a0b.jpeg)

**Specifications:**

> Windows 7 Professional x64 SP1, and also Windows 10 Professional x64 2004.  
> Packages installed Microsoft Visual C++ 2015-2022 Redistributable x86 and x64.  
> Tested with jdk-8u371-windows-x64.exe, or jdk-11.0.9\_windows-x64\_bin.exe, but the result did not change at the output.

**HelloTF.java:**

> import org.tensorflow.Graph;  
> import org.tensorflow.Session;  
> import org.tensorflow.Tensor;  
> import org.tensorflow.TensorFlow;
> 
> public class HelloTF {  
> public static void main(String args) throws Exception {  
> try (Graph g = new Graph()) {  
> final String value = "Hello from " + TensorFlow.version();
> 
> ```
> // Construct the computation graph with a single operation, a constant
> // named "MyConst" with a value "value".
> try (Tensor t = Tensor.create(value.getBytes("UTF-8"))) {
> // The Java API doesn't yet include convenience functions for adding operations.
> g.opBuilder("Const", "MyConst").setAttr("dtype", t.dataType()).setAttr("value", t).build();
> }
> 
> // Execute the "MyConst" operation in a Session.
> try (Session s = new Session(g);
> Tensor output = s.runner().fetch("MyConst").run().get(0)) {
> System.out.println(new String(output.bytesValue(), "UTF-8"));
> }
> }
> 
> ```
> 
> }  
> }

**File links:**  
[libtensorflow-2.7.0.jar](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-2.7.0.jar)  
[libtensorflow\_jni-cpu-windows-x86\_64-2.7.0.zip](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow_jni-cpu-windows-x86_64-2.7.0.zip)  
[HelloTF.java](https://drive.google.com/file/d/10zjj8oU1cE7LdXXK8qIXuUm-Val_O8IV/view?usp=sharing)

Maybe the system needs to install more additional libraries ?  
Please, if you ran this library on Windows 7 x64, or Windows 10 x64, write how to do it correctly.

---

<div class="post-metadata">

**Author:** ![craigacp](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/craigacp/32/6331_2.png) [@craigacp](https://discuss.ai.google.dev/u/craigacp)\
**Post date:** [July 21, 2023, 2:02pm UTC](https://discuss.ai.google.dev/t/required-libraries-to-run-tensorflow-on-windows/31996/3 "2023-07-21T14:02:23Z")

</div>

Those binaries have never been supported for TF 2, development was moved out to SIG-JVM and you should use the binaries from this repo - [GitHub - tensorflow/java: Java bindings for TensorFlow](https://github.com/tensorflow/java), the latest release is 0.5.0 based on TF 2.10.1.

---

<div class="post-metadata">

**Author:** ![Robert\_Richard](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@Robert\_Richard](https://discuss.ai.google.dev/u/Robert_Richard)\
**Post date:** [July 22, 2023, 8:33pm UTC](https://discuss.ai.google.dev/t/required-libraries-to-run-tensorflow-on-windows/31996/4 "2023-07-22T20:33:55Z")

</div>

Thanks for your reply,

I made an attempt to run a test program, as in the description on [github Example Program](https://github.com/tensorflow/java/blob/master/docs/install.md).

**Used for this:**  
“maven-3.9.3”  
“jdk-11.0.9”  
“Microsoft Visual C++ 2015-2022”  
“mingv64 x86\_64-8.1.0-release-win32-sjlj-rt\_v6”

Entered the code through the command line in Windows 7 pro x64, and the program builds ok:

> mvn -q -e -X -Djavacpp.platform=windows-x86\_64 compile

> [INFO] Compiling 1 source file with javac [debug target 11] to target\classes  
> [DEBUG] incrementalBuildHelper#afterRebuildExecution  
> [INFO] ------------------------------------------------------------------------  
> [INFO] BUILD SUCCESS  
> [INFO] ------------------------------------------------------------------------

But on startup there is an error:

> mvn -Djavacpp.platform=windows-x86\_64 exec:java

> Caused by: java.lang.UnsatisfiedLinkError: C:\Users\Николай.javacpp\cache\tensorflow-core-api-0.4.1-windows-x86\_64.jar\org\tensorflow\internal\c\_api\windows-x86\_64\jnitensorflow.dll: Can’t find dependent libraries

**Included dependencies in pom.xml:**

> tensorflow-core-platform 0.4.1  
> tensorflow-framework 0.4.1  
> javacpp 1.5.6  
> protobuf-java 3.19.4

[tensorflowtest.zip](https://drive.google.com/file/d/1CA8ZVhVrrj5CpXb_rs4ywuuvtwcHbY3k/view?usp=drive_link)

Maybe there are not enough dependencies in the pom file, or am I building the project incorrectly?

---

<div class="post-metadata">

**Author:** ![craigacp](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/craigacp/32/6331_2.png) [@craigacp](https://discuss.ai.google.dev/u/craigacp)\
**Post date:** [July 22, 2023, 8:46pm UTC](https://discuss.ai.google.dev/t/required-libraries-to-run-tensorflow-on-windows/31996/5 "2023-07-22T20:46:13Z")

</div>

Is there a reason you need to use version 0.4.1?

---

<div class="post-metadata">

**Author:** ![Robert\_Richard](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@Robert\_Richard](https://discuss.ai.google.dev/u/Robert_Richard)\
**Post date:** [July 22, 2023, 9:16pm UTC](https://discuss.ai.google.dev/t/required-libraries-to-run-tensorflow-on-windows/31996/6 "2023-07-22T21:16:32Z")

</div>

It is important for me now to run any java Tensorflow library with a version higher than 2.x.x on a Windows system, but I can’t get the dependencies right.

---

<div class="post-metadata">

**Author:** ![craigacp](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/craigacp/32/6331_2.png) [@craigacp](https://discuss.ai.google.dev/u/craigacp)\
**Post date:** [July 23, 2023, 12:06am UTC](https://discuss.ai.google.dev/t/required-libraries-to-run-tensorflow-on-windows/31996/7 "2023-07-23T00:06:13Z")

</div>

The error says it can’t load something transitively pulled in from the jnitensorflow dll. I suspect it’s because we build it on Windows 10 (or a Windows Server variant derived from Windows 10) and you’re using Windows 7. You can use a tool like dumpbin which comes with Visual Studio to find the dependencies that dll needs, but I think you might need to build it from source on that platform to make it work.

---

<div class="post-metadata">

**Author:** ![Robert\_Richard](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@Robert\_Richard](https://discuss.ai.google.dev/u/Robert_Richard)\
**Post date:** [July 23, 2023, 4:05am UTC](https://discuss.ai.google.dev/t/required-libraries-to-run-tensorflow-on-windows/31996/8 "2023-07-23T04:05:46Z")

</div>

I will use the same test on Windows 10.  
Please, write what libraries you have installed on Windows to use java Tensorflow. Maybe I missed something when reading the documentation.

---

<div class="post-metadata">

**Author:** ![craigacp](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/craigacp/32/6331_2.png) [@craigacp](https://discuss.ai.google.dev/u/craigacp)\
**Post date:** [July 23, 2023, 4:17am UTC](https://discuss.ai.google.dev/t/required-libraries-to-run-tensorflow-on-windows/31996/9 "2023-07-23T04:17:48Z")

</div>

I very rarely run TF-Java locally on Windows, but I do use it in GitHub Actions runs on their Windows runners, so you could look at the packages installed there. I don’t think we install anything special.
