diff --git a/README.md b/README.md index 00cacf870c4..595c096529a 100644 --- a/README.md +++ b/README.md @@ -44,17 +44,17 @@ See [CONTRIBUTING.md](CONTRIBUTING.md#building). ## Using Maven Artifacts There are two options for adding TensorFlow Java as a dependency to your Maven project: with individual dependencies -for each targeted platforms or with a single dependency that target them all. +for each targeted platform or with a single dependency that targets them all. ### Individual dependencies With this option, you must first add a dependency to `tensorflow-core-api` and then one or multiple dependencies to `tensorflow-core-native` with a classifier targeting a specific platform. This option is preferred as -it minimize the size of your application by only including the TensorFlow builds you need, at the cost of being more +it minimizes the size of your application by only including the TensorFlow builds you need, at the cost of being more restrictive. While TensorFlow Java can be compiled for [multiple platforms](https://github.com/tensorflow/java/blob/master/tensorflow-core/pom.xml#L54), -only binaries for the followings are being **supported and distributed** by this project: +only binaries for the following are being **supported and distributed** by this project: - `linux-x86_64`: Linux platforms on Intel/AMD chips - `linux-x86_64-gpu`: Linux platforms on Intel/AMD chips with Cuda GPU support @@ -80,6 +80,12 @@ systems with no GPU support, you should add the following dependencies: linux-x86_64 ``` +Or Gradle: +```groovy +def tfVersion = '1.0.0' +implementation "org.tensorflow:tensorflow-core-api:$tfVersion" +implementation "org.tensorflow:tensorflow-core-native:$tfVersion:linux-x86_64" +``` On the other hand, if you plan to deploy your JAR on more platforms, you need additional native dependencies as follows: @@ -108,13 +114,21 @@ native dependencies as follows: windows-x86_64 ``` +Or Gradle: +```groovy +def tfVersion = '1.0.0' +implementation "org.tensorflow:tensorflow-core-api:$tfVersion" +implementation "org.tensorflow:tensorflow-core-native:$tfVersion:linux-x86_64-gpu" +implementation "org.tensorflow:tensorflow-core-native:$tfVersion:macosx-arm64" +implementation "org.tensorflow:tensorflow-core-native:$tfVersion:windows-x86_64" +``` Only one dependency can be added per platform, meaning that you cannot add native dependencies to both `linux-x86_64` and `linux-x86_64-gpu` within the same project. To use an NVIDIA GPU, you need to install the NVIDIA device driver, CUDA Toolkit, and cuDNN. For Ubuntu 24.04, you can install them with the following command: -```sudo apt-get install -y nvidia-driver-550 nvidia-cuda-toolkit nvidia-cudnn``` +```sudo apt install -y nvidia-driver-550 nvidia-cuda-toolkit nvidia-cudnn``` ### Single dependency @@ -132,6 +146,10 @@ simply add this dependency to your application: 1.0.0 ``` +Or Gradle: +```groovy +implementation "org.tensorflow:tensorflow-core-platform:1.0.0" +``` Be aware though that the builds of TensorFlow are quite voluminous and including too many native dependencies may significantly increase the size of your application. So it is good practice to limit your dependencies to @@ -163,6 +181,20 @@ to add Sonatype OSS repository in your pom.xml, like the following ``` +Or Gradle: +```groovy +repositories { + mavenCentral() + maven { + url = uri("https://oss.sonatype.org/content/repositories/snapshots") + } +} + +dependencies { + // Example of dependency, see section above for more options + implementation "org.tensorflow:tensorflow-core-platform:1.1.0-SNAPSHOT" +} +``` ## TensorFlow/Java Version Support