Skip to content

Commit

Permalink
Fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
karllessard committed May 17, 2020
1 parent 9d0a6c8 commit 4b52381
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions tensorflow-core/tensorflow-core-api/build.sh
Expand Up @@ -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

Expand All @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tensorflow-core/tensorflow-core-api/pom.xml
Expand Up @@ -318,6 +318,9 @@
-Djava.library.path=${project.build.directory}/native/org/tensorflow/internal/c_api/${native.classifier}
</argLine>
<additionalClasspathElements>${project.build.directory}/native/</additionalClasspathElements>
<systemPropertyVariables>
<NATIVE_PLATFORM>${javacpp.platform}</NATIVE_PLATFORM>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
Expand Down
Expand Up @@ -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;

Expand All @@ -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 {
Expand All @@ -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()));
}
}

0 comments on commit 4b52381

Please sign in to comment.