Skip to content

Build the tensorflow_cc target instead of just tensorflow #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
linux-x86_64:
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'CI build')
runs-on: ubuntu-latest
container: nvidia/cuda:10.1-cudnn7-devel-centos7
container: centos:7
strategy:
matrix:
ext: ["", -mkl, -gpu, -mkl-gpu]
Expand All @@ -39,6 +39,17 @@ jobs:
echo Downloading Bazel
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
bash bazel.sh
echo Installing CUDA
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
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
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
rpm -i $HOME/cuda.rpm
cd /var/cuda-repo-10-1-local-10.1.243-418.87.00/; rpm -i --nodeps cuda*.rpm libc*.rpm
ln -sf /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/libcuda.so
ln -sf /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/libnvidia-ml.so
tar hxvf $HOME/cudnn.tgz -C /usr/local/
tar hxvf $HOME/nccl.txz --strip-components=1 -C /usr/local/cuda/
mv /usr/local/cuda/lib/* /usr/local/cuda/lib64/
- name: Checkout repository
uses: actions/checkout@v1
- name: Build project
Expand Down Expand Up @@ -110,7 +121,7 @@ jobs:
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
echo Installing CUDA
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
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
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
cuda.exe -s
mkdir cuda
unzip.exe cudnn.zip
Expand Down
23 changes: 12 additions & 11 deletions tensorflow-core/tensorflow-core-api/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fi

if [[ "${EXTENSION:-}" == *gpu* ]]; then
export BUILD_FLAGS="$BUILD_FLAGS --config=cuda"
export TF_CUDA_COMPUTE_CAPABILITIES="3.5,7.0"
if [[ -z ${TF_CUDA_PATHS:-} ]] && [[ -d ${CUDA_PATH:-} ]]; then
# Work around some issue with Bazel preventing it from detecting CUDA on Windows
export TF_CUDA_PATHS="$CUDA_PATH"
Expand All @@ -35,9 +36,9 @@ BUILD_FLAGS="$BUILD_FLAGS --experimental_repo_remote_exec --python_path="$PYTHON
# 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
# Build C/C++ API of TensorFlow itself including a target to generate ops for Java
bazel build $BUILD_FLAGS \
@org_tensorflow//tensorflow:tensorflow \
@org_tensorflow//tensorflow:tensorflow_cc \
@org_tensorflow//tensorflow/tools/lib_package:jnilicenses_generate \
:java_proto_gen_sources \
:java_op_generator \
Expand All @@ -49,23 +50,23 @@ export BAZEL_BIN=$(pwd -P)/bazel-bin
export TENSORFLOW_BIN=$BAZEL_BIN/external/org_tensorflow/tensorflow

# Normalize some paths with symbolic links
TENSORFLOW_SO=($TENSORFLOW_BIN/libtensorflow.so.?.?.?)
TENSORFLOW_SO=($TENSORFLOW_BIN/libtensorflow_cc.so.?.?.?)
if [[ -f $TENSORFLOW_SO ]]; then
export TENSORFLOW_LIB=$TENSORFLOW_SO
ln -sf $(basename $TENSORFLOW_SO) $TENSORFLOW_BIN/libtensorflow.so
ln -sf $(basename $TENSORFLOW_SO) $TENSORFLOW_BIN/libtensorflow.so.2
ln -sf $(basename $TENSORFLOW_SO) $TENSORFLOW_BIN/libtensorflow_cc.so
ln -sf $(basename $TENSORFLOW_SO) $TENSORFLOW_BIN/libtensorflow_cc.so.2
fi
TENSORFLOW_DYLIB=($TENSORFLOW_BIN/libtensorflow.?.?.?.dylib)
TENSORFLOW_DYLIB=($TENSORFLOW_BIN/libtensorflow_cc.?.?.?.dylib)
if [[ -f $TENSORFLOW_DYLIB ]]; then
export TENSORFLOW_LIB=$TENSORFLOW_DYLIB
ln -sf $(basename $TENSORFLOW_DYLIB) $TENSORFLOW_BIN/libtensorflow.dylib
ln -sf $(basename $TENSORFLOW_DYLIB) $TENSORFLOW_BIN/libtensorflow.2.dylib
ln -sf $(basename $TENSORFLOW_DYLIB) $TENSORFLOW_BIN/libtensorflow_cc.dylib
ln -sf $(basename $TENSORFLOW_DYLIB) $TENSORFLOW_BIN/libtensorflow_cc.2.dylib
fi
TENSORFLOW_DLLS=($TENSORFLOW_BIN/tensorflow.dll.if.lib $TENSORFLOW_BIN/libtensorflow.dll.ifso)
TENSORFLOW_DLLS=($TENSORFLOW_BIN/tensorflow_cc.dll.if.lib $TENSORFLOW_BIN/libtensorflow_cc.dll.ifso)
for TENSORFLOW_DLL in ${TENSORFLOW_DLLS[@]}; do
if [[ -f $TENSORFLOW_DLL ]]; then
export TENSORFLOW_LIB=$TENSORFLOW_BIN/tensorflow.dll
ln -sf $(basename $TENSORFLOW_DLL) $TENSORFLOW_BIN/tensorflow.lib
export TENSORFLOW_LIB=$TENSORFLOW_BIN/tensorflow_cc.dll
ln -sf $(basename $TENSORFLOW_DLL) $TENSORFLOW_BIN/tensorflow_cc.lib
fi
done
echo "Listing $TENSORFLOW_BIN:" && ls -l $TENSORFLOW_BIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,57 @@
public class tensorflow extends org.tensorflow.internal.c_api.presets.tensorflow {
static { Loader.load(); }

// Parsed from tensorflow/core/util/port.h

/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

// #ifndef TENSORFLOW_CORE_UTIL_PORT_H_
// #define TENSORFLOW_CORE_UTIL_PORT_H_

// Returns true if GOOGLE_CUDA is defined.
@Namespace("tensorflow") public static native @Cast("bool") boolean IsGoogleCudaEnabled();

// Returns true if TENSORFLOW_USE_ROCM is defined. (i.e. TF is built with ROCm)
@Namespace("tensorflow") public static native @Cast("bool") boolean IsBuiltWithROCm();

// Returns true if TENSORFLOW_USE_XLA is defined. (i.e. TF is built with XLA)
@Namespace("tensorflow") public static native @Cast("bool") boolean IsBuiltWithXLA();

// Returns true if TENSORFLOW_USE_NVCC is defined. (i.e. TF is built with nvcc)
@Namespace("tensorflow") public static native @Cast("bool") boolean IsBuiltWithNvcc();

// Returns true if either
//
// GOOGLE_CUDA is defined, and the given CUDA version supports
// half-precision matrix multiplications and convolution operations.
//
// OR
//
// TENSORFLOW_USE_ROCM is defined
//
@Namespace("tensorflow") public static native @Cast("bool") boolean GpuSupportsHalfMatMulAndConv();

// Returns true if INTEL_MKL is defined
@Namespace("tensorflow") public static native @Cast("bool") boolean IsMklEnabled();

// end namespace tensorflow

// #endif // TENSORFLOW_CORE_UTIL_PORT_H_


// Parsed from tensorflow/c/tf_attrtype.h

/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
value = {"linux", "macosx", "windows"},
compiler = "cpp11",
include = {
"tensorflow/core/util/port.h",
"tensorflow/c/tf_attrtype.h",
"tensorflow/c/tf_datatype.h",
"tensorflow/c/tf_status.h",
Expand All @@ -48,7 +49,7 @@
"tensorflow/c/ops.h",
"tensorflow/c/eager/c_api.h"
},
link = "tensorflow@.2",
link = "tensorflow_cc@.2",
preload = {"iomp5", "mklml", "mklml_intel", "[email protected]"},
preloadresource = "/org/bytedeco/mkldnn/",
resource = {"LICENSE", "THIRD_PARTY_TF_JNI_LICENSES"}
Expand Down