Skip to content

Commit 428e762

Browse files
Craigacpkarllessard
authored andcommitted
Adding Linux x86_64 support (currently uses GPU binaries).
1 parent cc3e816 commit 428e762

File tree

5 files changed

+74
-28
lines changed

5 files changed

+74
-28
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ xcuserdata/**
3636
/api_init_files_list.txt
3737
/estimator_api_init_files_list.txt
3838
*.whl
39+
tensorflow-core/tensorflow-core-api/downloads/
40+
41+
# Vim backups
42+
*~
3943

4044
# Patch files
4145
*.orig

tensorflow-core/pom.xml

+39
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@
7070
<javacpp.version>1.5.9</javacpp.version>
7171

7272
<native.wheel.url/>
73+
<native.wheel.url.linux-x86_64>https://files.pythonhosted.org/packages/6b/6d/00ef55900312ba8c8aa9d64b13c74fb8cba0afa24cc4a2ce74796f530244/tensorflow-2.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl</native.wheel.url.linux-x86_64>
74+
<native.wheel.url.macosx-x86_64>https://files.pythonhosted.org/packages/67/4a/a39d10a1f2f3b13bc845a13d7f7f771fa93ee67fc36c697ade5c203727b3/tensorflow_macos-2.12.0-cp311-cp311-macosx_12_0_x86_64.whl</native.wheel.url.macosx-x86_64>
7375
<native.wheel.url.macosx-arm64>https://files.pythonhosted.org/packages/d2/e6/94748fedae940a7095ac3acb821e613f72513cf9fa8ea0cf6fe734ef8c8f/tensorflow_macos-2.12.0-cp311-cp311-macosx_12_0_arm64.whl</native.wheel.url.macosx-arm64>
76+
<native.wheel.url.windows-x86_64>https://files.pythonhosted.org/packages/2c/14/5ae30837269512867efbfa7144b45e816db43b98e3f663f5a51a8148d5c3/tensorflow_intel-2.12.0-cp311-cp311-win_amd64.whl</native.wheel.url.windows-x86_64>
7477
</properties>
7578

7679
<profiles>
@@ -873,6 +876,18 @@
873876
<os.name>linux</os.name>
874877
</properties>
875878
</profile>
879+
<profile>
880+
<id>linux-x86_64</id>
881+
<activation>
882+
<os>
883+
<name>linux</name>
884+
<arch>amd64</arch>
885+
</os>
886+
</activation>
887+
<properties>
888+
<native.wheel.url>${native.wheel.url.linux-x86_64}</native.wheel.url>
889+
</properties>
890+
</profile>
876891
<profile>
877892
<id>macosx</id>
878893
<activation>
@@ -883,6 +898,18 @@
883898
<os.name>macosx</os.name>
884899
</properties>
885900
</profile>
901+
<profile>
902+
<id>macosx-x86_64</id>
903+
<activation>
904+
<os>
905+
<name>mac os x</name>
906+
<arch>x86_64</arch>
907+
</os>
908+
</activation>
909+
<properties>
910+
<native.wheel.url>${native.wheel.url.macosx-x86_64}</native.wheel.url>
911+
</properties>
912+
</profile>
886913
<profile>
887914
<id>macosx-arm64</id>
888915
<activation>
@@ -905,6 +932,18 @@
905932
<os.name>windows</os.name>
906933
</properties>
907934
</profile>
935+
<profile>
936+
<id>windows-x86_64</id>
937+
<activation>
938+
<os>
939+
<name>windows</name>
940+
<arch>x86_64</arch>
941+
</os>
942+
</activation>
943+
<properties>
944+
<native.wheel.url>${native.wheel.url.windows-x86_64}</native.wheel.url>
945+
</properties>
946+
</profile>
908947
<profile>
909948
<id>arm</id>
910949
<activation>

tensorflow-core/tensorflow-core-api/pom.xml

+13-24
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
</plugin>
160160
<plugin>
161161
<artifactId>maven-resources-plugin</artifactId>
162-
<version>3.1.0</version>
162+
<version>3.3.1</version>
163163
<executions>
164164
<!--
165165
Important: Use a phase before "generate-sources" like "initialize" or Maven may move
@@ -177,7 +177,7 @@
177177

178178
<plugin>
179179
<artifactId>maven-compiler-plugin</artifactId>
180-
<version>3.8.0</version>
180+
<version>3.11.0</version>
181181
<executions>
182182
<!--
183183
Generate Ops classes
@@ -248,11 +248,6 @@
248248
<classPath>${project.build.outputDirectory}</classPath>
249249
<includePaths>
250250
<includePath>${project.basedir}/</includePath>
251-
<!-- <includePath>${project.basedir}/bazel-${project.artifactId}/external/org_tensorflow/</includePath>-->
252-
<!-- <includePath>${project.basedir}/bazel-bin/external/org_tensorflow/</includePath>-->
253-
<!-- <includePath>${project.basedir}/bazel-${project.artifactId}/external/com_google_absl/</includePath>-->
254-
<!-- <includePath>${project.basedir}/bazel-${project.artifactId}/external/eigen_archive/</includePath>-->
255-
<!-- <includePath>${project.basedir}/bazel-${project.artifactId}/external/com_google_protobuf/src/</includePath>-->
256251
<includePath>${project.basedir}/downloads/tensorflow/include/</includePath>
257252
<includePath>${project.basedir}/target/classes/org/tensorflow/internal/c_api/include/</includePath>
258253
</includePaths>
@@ -261,13 +256,7 @@
261256
</linkPaths>
262257
<resourcePaths>
263258
<resourcePath>${project.basedir}/../../</resourcePath>
264-
<resourcePath>${project.basedir}/bazel-bin/external/org_tensorflow/tensorflow/tools/lib_package/</resourcePath>
265259
</resourcePaths>
266-
<preloadPaths>
267-
<preloadPath>${project.basedir}/bazel-${project.artifactId}/external/mkl_linux/lib/</preloadPath>
268-
<preloadPath>${project.basedir}/bazel-${project.artifactId}/external/mkl_darwin/lib/</preloadPath>
269-
<preloadPath>${project.basedir}/bazel-${project.artifactId}/external/mkl_windows/lib/</preloadPath>
270-
</preloadPaths>
271260
</configuration>
272261
<executions>
273262
<execution>
@@ -299,9 +288,9 @@
299288
<buildCommand>
300289
<program>bash</program>
301290
<argument>prepare_build.sh</argument>
302-
<!--argument>${project.basedir}/build.sh</argument-->
303291
<argument>${native.wheel.url}</argument>
304292
<argument>${native.build.folder}</argument>
293+
<argument>${os.name}</argument>
305294
</buildCommand>
306295
<environmentVariables>
307296
<PLATFORM>${javacpp.platform}</PLATFORM>
@@ -311,12 +300,11 @@
311300
<workingDirectory>${project.basedir}</workingDirectory>
312301
</configuration>
313302
</execution>
314-
<execution>
315-
<!--
303+
<!-- Commented out while we remove bazel
304+
<execution>
316305
Clean TensorFlow native libraries
317-
When this gets executed, all libraries build and cached by Bazel will be deleted and
318-
will be rebuild on the next execution.
319-
-->
306+
When this gets executed, all libraries build and cached by Bazel will be deleted and
307+
will be rebuild on the next execution.
320308
<id>javacpp-clean</id>
321309
<phase>clean</phase>
322310
<goals>
@@ -331,6 +319,7 @@
331319
<workingDirectory>${project.basedir}</workingDirectory>
332320
</configuration>
333321
</execution>
322+
-->
334323
<execution>
335324
<!--
336325
Generate TensorFlow C API binding sources
@@ -384,7 +373,7 @@
384373
-->
385374
<groupId>org.codehaus.mojo</groupId>
386375
<artifactId>exec-maven-plugin</artifactId>
387-
<version>3.0.0</version>
376+
<version>3.1.0</version>
388377
<executions>
389378
<execution>
390379
<id>generate-ops</id>
@@ -413,11 +402,11 @@
413402
</plugin>
414403
<plugin>
415404
<artifactId>maven-jar-plugin</artifactId>
416-
<version>3.1.0</version>
405+
<version>3.3.0</version>
417406
<configuration>
418407
<archive>
419408
<manifestEntries>
420-
<Automatic-Module-Name>${java.module.name}</Automatic-Module-Name>
409+
<Automatic-Module-Name>org.tensorflow.core</Automatic-Module-Name>
421410
</manifestEntries>
422411
</archive>
423412
</configuration>
@@ -484,7 +473,7 @@
484473
</plugin>
485474
<plugin>
486475
<artifactId>maven-source-plugin</artifactId>
487-
<version>3.2.1</version>
476+
<version>3.3.0</version>
488477
<executions>
489478
<execution>
490479
<id>attach-sources</id>
@@ -500,7 +489,7 @@
500489
</plugin>
501490
<plugin>
502491
<artifactId>maven-javadoc-plugin</artifactId>
503-
<version>3.2.0</version>
492+
<version>3.5.0</version>
504493
<executions>
505494
<execution>
506495
<id>attach-javadocs</id>

tensorflow-core/tensorflow-core-api/prepare_build.sh

+16-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -eu
33

44
PYTHON_WHEEL_URL="$1"
55
TARGET_FOLDER="$2"
6+
OS_NAME="$3"
67
DOWNLOAD_FOLDER="downloads"
78
DOWNLOADED_FILE="tensorflow.zip" # TODO extract name from wheel url, change .whl to .zip
89

@@ -16,6 +17,18 @@ fi
1617
unzip -u -d $DOWNLOAD_FOLDER $DOWNLOAD_FOLDER/$DOWNLOADED_FILE
1718

1819
# TODO Per OS logic
19-
mv -f $DOWNLOAD_FOLDER/tensorflow/libtensorflow_cc.2.dylib $DOWNLOAD_FOLDER/tensorflow/libtensorflow_framework.2.dylib $TARGET_FOLDER
20-
ln -s $TARGET_FOLDER/libtensorflow_cc.2.dylib $TARGET_FOLDER/libtensorflow_cc.dylib
21-
ln -s $TARGET_FOLDER/libtensorflow_framework.2.dylib $TARGET_FOLDER/libtensorflow_framework.dylib
20+
if [ "$OS_NAME" = "linux" ]; then
21+
mv -f $DOWNLOAD_FOLDER/tensorflow/libtensorflow_cc.so.2 $DOWNLOAD_FOLDER/tensorflow/libtensorflow_framework.so.2 $TARGET_FOLDER
22+
ln -fs $TARGET_FOLDER/libtensorflow_cc.so.2 $TARGET_FOLDER/libtensorflow_cc.so
23+
ln -fs $TARGET_FOLDER/libtensorflow_framework.so.2 $TARGET_FOLDER/libtensorflow_framework.so
24+
elif [ "$OS_NAME" = "mac os x" ]; then
25+
mv -f $DOWNLOAD_FOLDER/tensorflow/libtensorflow_cc.2.dylib $DOWNLOAD_FOLDER/tensorflow/libtensorflow_framework.2.dylib $TARGET_FOLDER
26+
ln -s $TARGET_FOLDER/libtensorflow_cc.2.dylib $TARGET_FOLDER/libtensorflow_cc.dylib
27+
ln -s $TARGET_FOLDER/libtensorflow_framework.2.dylib $TARGET_FOLDER/libtensorflow_framework.dylib
28+
elif [ "$OS_NAME" = "windows" ]; then
29+
cat "Windows unsupported";
30+
return 1;
31+
else
32+
cat "Invalid OS $OS_NAME";
33+
return 1;
34+
fi

tensorflow-framework/src/main/java/module-info.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
=======================================================================
1616
*/
1717
module org.tensorflow.framework {
18-
requires org.tensorflow;
18+
requires org.tensorflow.core;
19+
requires org.tensorflow.ndarray;
1920

2021
exports org.tensorflow.framework.activations;
2122
exports org.tensorflow.framework.constraints;

0 commit comments

Comments
 (0)