|
1 | 1 | # TensorFlow for Java |
2 | 2 |
|
3 | | -> *WARNING*: The TensorFlow Java API is not currently covered by the TensorFlow |
4 | | -> [API stability guarantees](https://www.tensorflow.org/guide/version_compat). |
| 3 | +> *WARNING*: This version of the Java client is deprecated and has been replaced by a new version that is maintained |
| 4 | +> in its own [repository](https://github.com/tensorflow/java) under the TensorFlow organization. |
5 | 5 | > |
6 | | -> For using TensorFlow on Android refer instead to [TensorFlow Lite](https://www.tensorflow.org/code/tensorflow/lite/). |
| 6 | +> For using TensorFlow on a JVM, please refer to new [TensorFlow Java](https://www.tensorflow.org/jvm/install). |
| 7 | +> For using TensorFlow on Android, refer instead to [TensorFlow Lite](https://www.tensorflow.org/code/tensorflow/lite/). |
7 | 8 |
|
8 | | -## Quickstart |
9 | | - |
10 | | -- Refer to [Installing TensorFlow for Java](https://www.tensorflow.org/install/lang_java) |
11 | | -- [Javadoc](https://www.tensorflow.org/api_docs/java/reference/org/tensorflow/package-summary) |
12 | | -- [](https://maven-badges.herokuapp.com/maven-central/org.tensorflow/tensorflow) |
13 | | - |
14 | | -## Nightly builds |
15 | | - |
16 | | -Releases built from release branches are available on Maven Central. |
17 | | -Additionally, every day binaries are built from the `master` branch on GitHub: |
18 | | - |
19 | | -- [JAR](https://storage.googleapis.com/tensorflow-nightly/github/tensorflow/lib_package/libtensorflow.jar) |
20 | | -- [Source JAR](https://storage.googleapis.com/tensorflow-nightly/github/tensorflow/lib_package/libtensorflow-src.jar) |
21 | | -- JNI: |
22 | | - - [Linux CPU-only](https://storage.googleapis.com/tensorflow-nightly/github/tensorflow/lib_package/libtensorflow_jni-cpu-linux-x86_64.tar.gz) |
23 | | - - [Linux GPU](https://storage.googleapis.com/tensorflow-nightly/github/tensorflow/lib_package/libtensorflow_jni-gpu-linux-x86_64.tar.gz) |
24 | | - - [MacOS](https://storage.googleapis.com/tensorflow-nightly/github/tensorflow/lib_package/libtensorflow_jni-cpu-darwin-x86_64.tar.gz) |
25 | | - - Windows: (No nightly builds available yet) |
26 | | - |
27 | | -## Building from source |
28 | | - |
29 | | -If the quickstart instructions above do not work out, the TensorFlow Java and |
30 | | -native libraries will need to be built from source. |
31 | | - |
32 | | -1. Install [bazel](https://www.bazel.build/versions/master/docs/install.html) |
33 | | - |
34 | | -2. Setup the environment to build TensorFlow from source code |
35 | | - ([Linux or macOS](https://www.tensorflow.org/install/source)). |
36 | | - If you'd like to skip reading those details and do not care about GPU |
37 | | - support, try the following: |
38 | | - |
39 | | - ```sh |
40 | | - # On Linux |
41 | | - sudo apt-get install python swig python-numpy |
42 | | - |
43 | | - # On Mac OS X with homebrew |
44 | | - brew install swig |
45 | | - ``` |
46 | | - |
47 | | -3. [Configure](https://www.tensorflow.org/install/source) |
48 | | - (e.g., enable GPU support) and build: |
49 | | - |
50 | | - ```sh |
51 | | - ./configure |
52 | | - bazel build --config opt \ |
53 | | - //tensorflow/java:tensorflow \ |
54 | | - //tensorflow/java:libtensorflow_jni |
55 | | - ``` |
56 | | - |
57 | | -The command above will produce two files in the `bazel-bin/tensorflow/java` |
58 | | -directory: |
59 | | - |
60 | | -* An archive of Java classes: `libtensorflow.jar` |
61 | | -* A native library: `libtensorflow_jni.so` on Linux, `libtensorflow_jni.dylib` |
62 | | - on OS X, or `tensorflow_jni.dll` on Windows. |
63 | | - |
64 | | -To compile Java code that uses the TensorFlow Java API, include |
65 | | -`libtensorflow.jar` in the classpath. For example: |
66 | | - |
67 | | -```sh |
68 | | -javac -cp bazel-bin/tensorflow/java/libtensorflow.jar ... |
69 | | -``` |
70 | | - |
71 | | -To execute the compiled program, include `libtensorflow.jar` in the classpath |
72 | | -and the native library in the library path. For example: |
73 | | - |
74 | | -```sh |
75 | | -java -cp bazel-bin/tensorflow/java/libtensorflow.jar \ |
76 | | - -Djava.library.path=bazel-bin/tensorflow/java \ |
77 | | - ... |
78 | | -``` |
79 | | - |
80 | | -Installation on Windows requires the more experimental [bazel on |
81 | | -Windows](https://bazel.build/versions/master/docs/windows.html). Details are |
82 | | -omitted here, but find inspiration in the script used for building the release |
83 | | -archive: |
84 | | -[`tensorflow/tools/ci_build/windows/libtensorflow_cpu.sh`](https://www.tensorflow.org/code/tensorflow/tools/ci_build/windows/libtensorflow_cpu.sh). |
85 | | - |
86 | | -### Bazel |
87 | | - |
88 | | -If your project uses bazel for builds, add a dependency on |
89 | | -`//tensorflow/java:tensorflow` to the `java_binary` or `java_library` rule. For |
90 | | -example: |
91 | | - |
92 | | -```sh |
93 | | -bazel run -c opt //tensorflow/java/src/main/java/org/tensorflow/examples:label_image |
94 | | -``` |
| 9 | +Follow this [link](LEGACY.md) for legacy instructions. |
0 commit comments