Skip to content

Commit 5a7f7f1

Browse files
add Gradle snippets to README.md
1 parent b957e64 commit 5a7f7f1

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ See [CONTRIBUTING.md](CONTRIBUTING.md#building).
4444
## Using Maven Artifacts
4545

4646
There are two options for adding TensorFlow Java as a dependency to your Maven project: with individual dependencies
47-
for each targeted platforms or with a single dependency that target them all.
47+
for each targeted platform or with a single dependency that targets them all.
4848

4949
### Individual dependencies
5050

5151
With this option, you must first add a dependency to `tensorflow-core-api` and then one or multiple
5252
dependencies to `tensorflow-core-native` with a classifier targeting a specific platform. This option is preferred as
53-
it minimize the size of your application by only including the TensorFlow builds you need, at the cost of being more
53+
it minimizes the size of your application by only including the TensorFlow builds you need, at the cost of being more
5454
restrictive.
5555

5656
While TensorFlow Java can be compiled for [multiple platforms](https://github.com/tensorflow/java/blob/master/tensorflow-core/pom.xml#L54),
57-
only binaries for the followings are being **supported and distributed** by this project:
57+
only binaries for the following are being **supported and distributed** by this project:
5858

5959
- `linux-x86_64`: Linux platforms on Intel/AMD chips
6060
- `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:
8080
<classifier>linux-x86_64</classifier>
8181
</dependency>
8282
```
83+
Or Gradle:
84+
```groovy
85+
def tfVersion = '1.0.0'
86+
implementation "org.tensorflow:tensorflow-core-api:$tfVersion"
87+
implementation "org.tensorflow:tensorflow-core-native:$tfVersion:linux-x86_64"
88+
```
8389

8490
On the other hand, if you plan to deploy your JAR on more platforms, you need additional
8591
native dependencies as follows:
@@ -108,13 +114,21 @@ native dependencies as follows:
108114
<classifier>windows-x86_64</classifier>
109115
</dependency>
110116
```
117+
Or Gradle:
118+
```groovy
119+
def tfVersion = '1.0.0'
120+
implementation "org.tensorflow:tensorflow-core-api:$tfVersion"
121+
implementation "org.tensorflow:tensorflow-core-native:$tfVersion:linux-x86_64-gpu"
122+
implementation "org.tensorflow:tensorflow-core-native:$tfVersion:macosx-arm64"
123+
implementation "org.tensorflow:tensorflow-core-native:$tfVersion:windows-x86_64"
124+
```
111125

112126
Only one dependency can be added per platform, meaning that you cannot add native dependencies to both `linux-x86_64` and
113127
`linux-x86_64-gpu` within the same project.
114128

115129
To use an NVIDIA GPU, you need to install the NVIDIA device driver, CUDA Toolkit, and cuDNN.
116130
For Ubuntu 24.04, you can install them with the following command:
117-
```sudo apt-get install -y nvidia-driver-550 nvidia-cuda-toolkit nvidia-cudnn```
131+
```sudo apt install -y nvidia-driver-550 nvidia-cuda-toolkit nvidia-cudnn```
118132

119133
### Single dependency
120134

@@ -132,6 +146,10 @@ simply add this dependency to your application:
132146
<version>1.0.0</version>
133147
</dependency>
134148
```
149+
Or Gradle:
150+
```groovy
151+
implementation "org.tensorflow:tensorflow-core-platform:1.0.0"
152+
```
135153

136154
Be aware though that the builds of TensorFlow are quite voluminous and including too many native dependencies may
137155
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
163181
</dependency>
164182
</dependencies>
165183
```
184+
Or Gradle:
185+
```groovy
186+
repositories {
187+
mavenCentral()
188+
maven {
189+
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
190+
}
191+
}
192+
193+
dependencies {
194+
// Example of dependency, see section above for more options
195+
implementation "org.tensorflow:tensorflow-core-platform:1.1.0-SNAPSHOT"
196+
}
197+
```
166198

167199
## TensorFlow/Java Version Support
168200

0 commit comments

Comments
 (0)