From 4b52381a3875433e75ec4303f91daea1647a17dd Mon Sep 17 00:00:00 2001 From: Karl Lessard Date: Sat, 16 May 2020 19:46:56 -0400 Subject: [PATCH] Fix windows build --- .github/workflows/ci.yml | 1 + tensorflow-core/tensorflow-core-api/build.sh | 12 +++++++++--- tensorflow-core/tensorflow-core-api/pom.xml | 3 +++ .../src/test/java/org/tensorflow/TensorFlowTest.java | 10 ++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2e8336fa2c..62b2ee88fed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,6 +100,7 @@ jobs: mkdir cuda unzip.exe cudnn.zip cp.exe -a cuda/include cuda/lib cuda/bin "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/" + echo %JAVA_HOME% - name: Checkout repository uses: actions/checkout@v1 - name: Build project diff --git a/tensorflow-core/tensorflow-core-api/build.sh b/tensorflow-core/tensorflow-core-api/build.sh index 2523d6f7f29..6b16cfcb2f6 100755 --- a/tensorflow-core/tensorflow-core-api/build.sh +++ b/tensorflow-core/tensorflow-core-api/build.sh @@ -18,6 +18,7 @@ else fi if [[ "${EXTENSION:-}" == *mkl* ]]; then + # Don't use MKL-DNN v1 as it is only currently supported by Linux platform export BUILD_FLAGS="$BUILD_FLAGS --config=mkl --define build_with_mkl_dnn_v1_only=false" fi @@ -29,8 +30,13 @@ if [[ "${EXTENSION:-}" == *gpu* ]]; then fi fi +BUILD_FLAGS="$BUILD_FLAGS --experimental_repo_remote_exec --python_path="$PYTHON_BIN_PATH" --output_filter=DONT_MATCH_ANYTHING --verbose_failures" + +# Always allow distinct host configuration since we rely on the host JVM for a few things (this was disabled by default on windows) +BUILD_FLAGS="$BUILD_FLAGS --distinct_host_configuration=true" + # Build C API of TensorFlow itself including a target to generate ops for Java -bazel build $BUILD_FLAGS --experimental_repo_remote_exec --python_path="$PYTHON_BIN_PATH" --output_filter=DONT_MATCH_ANYTHING --verbose_failures \ +bazel build $BUILD_FLAGS \ @org_tensorflow//tensorflow:tensorflow \ @org_tensorflow//tensorflow/tools/lib_package:jnilicenses_generate \ :java_proto_gen_sources \ @@ -58,11 +64,11 @@ fi TENSORFLOW_DLLS=($TENSORFLOW_BIN/tensorflow.dll.if.lib $TENSORFLOW_BIN/libtensorflow.dll.ifso) for TENSORFLOW_DLL in ${TENSORFLOW_DLLS[@]}; do if [[ -f $TENSORFLOW_DLL ]]; then - export TENSORFLOW_LIB=$TENSORFLOW_DLL + export TENSORFLOW_LIB=$TENSORFLOW_BIN/tensorflow.dll ln -sf $(basename $TENSORFLOW_DLL) $TENSORFLOW_BIN/tensorflow.lib fi done -ls -l $TENSORFLOW_BIN +echo "Listing $TENSORFLOW_BIN:" && ls -l $TENSORFLOW_BIN GEN_SRCS_DIR=src/gen/java mkdir -p $GEN_SRCS_DIR diff --git a/tensorflow-core/tensorflow-core-api/pom.xml b/tensorflow-core/tensorflow-core-api/pom.xml index 92ea22ceea8..204f998946b 100644 --- a/tensorflow-core/tensorflow-core-api/pom.xml +++ b/tensorflow-core/tensorflow-core-api/pom.xml @@ -318,6 +318,9 @@ -Djava.library.path=${project.build.directory}/native/org/tensorflow/internal/c_api/${native.classifier} ${project.build.directory}/native/ + + ${javacpp.platform} + diff --git a/tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/TensorFlowTest.java b/tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/TensorFlowTest.java index 8d00a84349a..005569a3718 100644 --- a/tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/TensorFlowTest.java +++ b/tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/TensorFlowTest.java @@ -19,6 +19,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.junit.Assume.assumeFalse; import java.nio.file.Paths; @@ -43,6 +44,10 @@ public void registeredOpList() { @Test public void loadLibrary() { + // FIXME(karllessard) Custom ops libraries are not supported on Windows since TF is built monolithic + // Once we are able to lift this restriction, enable this test + disableOnPlatform("windows"); + try (Graph g = new Graph()) { // Build a graph with an unrecognized operation. try { @@ -62,4 +67,9 @@ public void loadLibrary() { g.opBuilder("MyTest", "MyTest").build(); } } + + private void disableOnPlatform(String platform) { + String current = System.getProperty("NATIVE_PLATFORM"); + assumeFalse(current != null && current.startsWith(platform.toLowerCase())); + } }