Skip to content

Commit 8c67525

Browse files
authored
Build the tensorflow_cc target instead of just tensorflow (#113)
1 parent 99659c0 commit 8c67525

File tree

4 files changed

+78
-14
lines changed

4 files changed

+78
-14
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
linux-x86_64:
2323
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'CI build')
2424
runs-on: ubuntu-latest
25-
container: nvidia/cuda:10.1-cudnn7-devel-centos7
25+
container: centos:7
2626
strategy:
2727
matrix:
2828
ext: ["", -mkl, -gpu, -mkl-gpu]
@@ -39,6 +39,17 @@ jobs:
3939
echo Downloading Bazel
4040
curl -L https://github.com/bazelbuild/bazel/releases/download/2.0.0/bazel-2.0.0-installer-linux-x86_64.sh -o bazel.sh --retry 10
4141
bash bazel.sh
42+
echo Installing CUDA
43+
curl -L https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-rhel7-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm -o $HOME/cuda.rpm
44+
curl -L https://developer.download.nvidia.com/compute/redist/cudnn/v7.6.5/cudnn-10.1-linux-x64-v7.6.5.32.tgz -o $HOME/cudnn.tgz
45+
curl -L https://developer.download.nvidia.com/compute/redist/nccl/v2.4/nccl_2.4.8-1+cuda10.1_x86_64.txz -o $HOME/nccl.txz
46+
rpm -i $HOME/cuda.rpm
47+
cd /var/cuda-repo-10-1-local-10.1.243-418.87.00/; rpm -i --nodeps cuda*.rpm libc*.rpm
48+
ln -sf /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/libcuda.so
49+
ln -sf /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/libnvidia-ml.so
50+
tar hxvf $HOME/cudnn.tgz -C /usr/local/
51+
tar hxvf $HOME/nccl.txz --strip-components=1 -C /usr/local/cuda/
52+
mv /usr/local/cuda/lib/* /usr/local/cuda/lib64/
4253
- name: Checkout repository
4354
uses: actions/checkout@v1
4455
- name: Build project
@@ -110,7 +121,7 @@ jobs:
110121
curl.exe -L https://github.com/bazelbuild/bazel/releases/download/2.0.0/bazel-2.0.0-windows-x86_64.exe -o C:/bazel/bazel.exe --retry 10
111122
echo Installing CUDA
112123
curl.exe -L http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_426.00_windows.exe -o cuda.exe
113-
curl.exe -L https://developer.download.nvidia.com/compute/redist/cudnn/v7.6.4/cudnn-10.1-windows7-x64-v7.6.4.38.zip -o cudnn.zip
124+
curl.exe -L https://developer.download.nvidia.com/compute/redist/cudnn/v7.6.5/cudnn-10.1-windows7-x64-v7.6.5.32.zip -o cudnn.zip
114125
cuda.exe -s
115126
mkdir cuda
116127
unzip.exe cudnn.zip

tensorflow-core/tensorflow-core-api/build.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fi
2424

2525
if [[ "${EXTENSION:-}" == *gpu* ]]; then
2626
export BUILD_FLAGS="$BUILD_FLAGS --config=cuda"
27+
export TF_CUDA_COMPUTE_CAPABILITIES="3.5,7.0"
2728
if [[ -z ${TF_CUDA_PATHS:-} ]] && [[ -d ${CUDA_PATH:-} ]]; then
2829
# Work around some issue with Bazel preventing it from detecting CUDA on Windows
2930
export TF_CUDA_PATHS="$CUDA_PATH"
@@ -35,9 +36,9 @@ BUILD_FLAGS="$BUILD_FLAGS --experimental_repo_remote_exec --python_path="$PYTHON
3536
# Always allow distinct host configuration since we rely on the host JVM for a few things (this was disabled by default on windows)
3637
BUILD_FLAGS="$BUILD_FLAGS --distinct_host_configuration=true"
3738

38-
# Build C API of TensorFlow itself including a target to generate ops for Java
39+
# Build C/C++ API of TensorFlow itself including a target to generate ops for Java
3940
bazel build $BUILD_FLAGS \
40-
@org_tensorflow//tensorflow:tensorflow \
41+
@org_tensorflow//tensorflow:tensorflow_cc \
4142
@org_tensorflow//tensorflow/tools/lib_package:jnilicenses_generate \
4243
:java_proto_gen_sources \
4344
:java_op_generator \
@@ -49,23 +50,23 @@ export BAZEL_BIN=$(pwd -P)/bazel-bin
4950
export TENSORFLOW_BIN=$BAZEL_BIN/external/org_tensorflow/tensorflow
5051

5152
# Normalize some paths with symbolic links
52-
TENSORFLOW_SO=($TENSORFLOW_BIN/libtensorflow.so.?.?.?)
53+
TENSORFLOW_SO=($TENSORFLOW_BIN/libtensorflow_cc.so.?.?.?)
5354
if [[ -f $TENSORFLOW_SO ]]; then
5455
export TENSORFLOW_LIB=$TENSORFLOW_SO
55-
ln -sf $(basename $TENSORFLOW_SO) $TENSORFLOW_BIN/libtensorflow.so
56-
ln -sf $(basename $TENSORFLOW_SO) $TENSORFLOW_BIN/libtensorflow.so.2
56+
ln -sf $(basename $TENSORFLOW_SO) $TENSORFLOW_BIN/libtensorflow_cc.so
57+
ln -sf $(basename $TENSORFLOW_SO) $TENSORFLOW_BIN/libtensorflow_cc.so.2
5758
fi
58-
TENSORFLOW_DYLIB=($TENSORFLOW_BIN/libtensorflow.?.?.?.dylib)
59+
TENSORFLOW_DYLIB=($TENSORFLOW_BIN/libtensorflow_cc.?.?.?.dylib)
5960
if [[ -f $TENSORFLOW_DYLIB ]]; then
6061
export TENSORFLOW_LIB=$TENSORFLOW_DYLIB
61-
ln -sf $(basename $TENSORFLOW_DYLIB) $TENSORFLOW_BIN/libtensorflow.dylib
62-
ln -sf $(basename $TENSORFLOW_DYLIB) $TENSORFLOW_BIN/libtensorflow.2.dylib
62+
ln -sf $(basename $TENSORFLOW_DYLIB) $TENSORFLOW_BIN/libtensorflow_cc.dylib
63+
ln -sf $(basename $TENSORFLOW_DYLIB) $TENSORFLOW_BIN/libtensorflow_cc.2.dylib
6364
fi
64-
TENSORFLOW_DLLS=($TENSORFLOW_BIN/tensorflow.dll.if.lib $TENSORFLOW_BIN/libtensorflow.dll.ifso)
65+
TENSORFLOW_DLLS=($TENSORFLOW_BIN/tensorflow_cc.dll.if.lib $TENSORFLOW_BIN/libtensorflow_cc.dll.ifso)
6566
for TENSORFLOW_DLL in ${TENSORFLOW_DLLS[@]}; do
6667
if [[ -f $TENSORFLOW_DLL ]]; then
67-
export TENSORFLOW_LIB=$TENSORFLOW_BIN/tensorflow.dll
68-
ln -sf $(basename $TENSORFLOW_DLL) $TENSORFLOW_BIN/tensorflow.lib
68+
export TENSORFLOW_LIB=$TENSORFLOW_BIN/tensorflow_cc.dll
69+
ln -sf $(basename $TENSORFLOW_DLL) $TENSORFLOW_BIN/tensorflow_cc.lib
6970
fi
7071
done
7172
echo "Listing $TENSORFLOW_BIN:" && ls -l $TENSORFLOW_BIN

tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/internal/c_api/global/tensorflow.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,57 @@
1111
public class tensorflow extends org.tensorflow.internal.c_api.presets.tensorflow {
1212
static { Loader.load(); }
1313

14+
// Parsed from tensorflow/core/util/port.h
15+
16+
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
17+
18+
Licensed under the Apache License, Version 2.0 (the "License");
19+
you may not use this file except in compliance with the License.
20+
You may obtain a copy of the License at
21+
22+
http://www.apache.org/licenses/LICENSE-2.0
23+
24+
Unless required by applicable law or agreed to in writing, software
25+
distributed under the License is distributed on an "AS IS" BASIS,
26+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
See the License for the specific language governing permissions and
28+
limitations under the License.
29+
==============================================================================*/
30+
31+
// #ifndef TENSORFLOW_CORE_UTIL_PORT_H_
32+
// #define TENSORFLOW_CORE_UTIL_PORT_H_
33+
34+
// Returns true if GOOGLE_CUDA is defined.
35+
@Namespace("tensorflow") public static native @Cast("bool") boolean IsGoogleCudaEnabled();
36+
37+
// Returns true if TENSORFLOW_USE_ROCM is defined. (i.e. TF is built with ROCm)
38+
@Namespace("tensorflow") public static native @Cast("bool") boolean IsBuiltWithROCm();
39+
40+
// Returns true if TENSORFLOW_USE_XLA is defined. (i.e. TF is built with XLA)
41+
@Namespace("tensorflow") public static native @Cast("bool") boolean IsBuiltWithXLA();
42+
43+
// Returns true if TENSORFLOW_USE_NVCC is defined. (i.e. TF is built with nvcc)
44+
@Namespace("tensorflow") public static native @Cast("bool") boolean IsBuiltWithNvcc();
45+
46+
// Returns true if either
47+
//
48+
// GOOGLE_CUDA is defined, and the given CUDA version supports
49+
// half-precision matrix multiplications and convolution operations.
50+
//
51+
// OR
52+
//
53+
// TENSORFLOW_USE_ROCM is defined
54+
//
55+
@Namespace("tensorflow") public static native @Cast("bool") boolean GpuSupportsHalfMatMulAndConv();
56+
57+
// Returns true if INTEL_MKL is defined
58+
@Namespace("tensorflow") public static native @Cast("bool") boolean IsMklEnabled();
59+
60+
// end namespace tensorflow
61+
62+
// #endif // TENSORFLOW_CORE_UTIL_PORT_H_
63+
64+
1465
// Parsed from tensorflow/c/tf_attrtype.h
1566

1667
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/internal/c_api/presets/tensorflow.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
value = {"linux", "macosx", "windows"},
3939
compiler = "cpp11",
4040
include = {
41+
"tensorflow/core/util/port.h",
4142
"tensorflow/c/tf_attrtype.h",
4243
"tensorflow/c/tf_datatype.h",
4344
"tensorflow/c/tf_status.h",
@@ -48,7 +49,7 @@
4849
"tensorflow/c/ops.h",
4950
"tensorflow/c/eager/c_api.h"
5051
},
51-
link = "tensorflow@.2",
52+
link = "tensorflow_cc@.2",
5253
preload = {"iomp5", "mklml", "mklml_intel", "[email protected]"},
5354
preloadresource = "/org/bytedeco/mkldnn/",
5455
resource = {"LICENSE", "THIRD_PARTY_TF_JNI_LICENSES"}

0 commit comments

Comments
 (0)