forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tensorflow] add new port for linux (microsoft#7568)
* [+] Add tensorflow-cc port (Linux only) * [~] Refactor installation of tensorflow/external 1. Install tensorflow/external to tensorflow-etc/external; 2. Fix TensorflowCCConfig.cmake accordingly. * [tensorflow] Work in progress * fix tensorflow linux config * [tensorflow] partial support for windows * fix config paths * use environmental variables instead * remove files * add python_path * add verbose error messages * review fixes * [tensorflow] refactor config file * minor changes * set arch for CI
- Loading branch information
Showing
5 changed files
with
182 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Source: tensorflow-cc | ||
Version: 1.14 | ||
Description: Library for computation using data flow graphs for scalable machine learning | ||
Build-Depends: c-ares |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
set(tensorflow_cc_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../include") | ||
|
||
message(WARNING "Tensorflow has vendored dependencies. You may need to manually include files from tensorflow-external") | ||
set(tensorflow_cc_INCLUDE_DIRS | ||
${tensorflow_cc_INCLUDE_DIR} | ||
${tensorflow_cc_INCLUDE_DIR}/tensorflow-external/ | ||
${tensorflow_cc_INCLUDE_DIR}/tensorflow-external/tensorflow/ | ||
${tensorflow_cc_INCLUDE_DIR}/tensorflow-external/external/com_google_absl | ||
${tensorflow_cc_INCLUDE_DIR}/tensorflow-external/bazel-out/k8-opt/bin/ | ||
${tensorflow_cc_INCLUDE_DIR}/tensorflow-external/external/protobuf_archive/src/ | ||
) | ||
|
||
add_library(tensorflow_cc::tensorflow_framework SHARED IMPORTED) | ||
set_target_properties(tensorflow_cc::tensorflow_framework | ||
PROPERTIES | ||
IMPORTED_LOCATION ${CMAKE_CURRENT_LIST_DIR}/../../lib/libtensorflow_framework.so.1.14.0 | ||
INTERFACE_INCLUDE_DIRECTORIES "${tensorflow_cc_INCLUDE_DIRS}" | ||
) | ||
|
||
add_library(tensorflow_cc::tensorflow_cc SHARED IMPORTED) | ||
set_target_properties(tensorflow_cc::tensorflow_cc | ||
PROPERTIES | ||
IMPORTED_LOCATION ${CMAKE_CURRENT_LIST_DIR}/../../lib/libtensorflow_cc.so.1.14.0 | ||
INTERFACE_INCLUDE_DIRECTORIES "${tensorflow_cc_INCLUDE_DIRS}" | ||
) | ||
|
||
set(tensorflow_cc_FOUND TRUE) | ||
set(tensorflow_framework_FOUND TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/configure.py b/configure.py | ||
index 43af22d..7989b1f 100644 | ||
--- a/configure.py | ||
+++ b/configure.py | ||
@@ -183,7 +183,7 @@ def get_python_path(environ_cp, python_bin_path): | ||
|
||
paths = [] | ||
for path in all_paths: | ||
- if os.path.isdir(path): | ||
+ if os.path.isdir(path) or True: | ||
paths.append(path) | ||
return paths | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
include(vcpkg_common_functions) | ||
|
||
message(WARNING "This tensorflow port currently is experimental on Windows and Linux platforms.") | ||
|
||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO tensorflow/tensorflow | ||
REF v1.14.0 | ||
SHA512 ac9ea5a2d1c761aaafbdc335259e29c128127b8d069ec5b206067935180490aa95e93c7e13de57f7f54ce4ba4f34a822face22b4a028f60185edb380e5cd4787 | ||
HEAD_REF master | ||
PATCHES | ||
file-exists.patch # required or otherwise it cant find python lib path on windows | ||
) | ||
|
||
# due to https://github.com/bazelbuild/bazel/issues/8028, bazel must be version 25.0 or higher | ||
vcpkg_find_acquire_program(BAZEL) | ||
get_filename_component(BAZEL_DIR "${BAZEL}" DIRECTORY) | ||
vcpkg_add_to_path(PREPEND ${BAZEL_DIR}) | ||
set(ENV{BAZEL_BIN_PATH} "${BAZEL}") | ||
|
||
vcpkg_find_acquire_program(PYTHON3) | ||
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) | ||
vcpkg_add_to_path(PREPEND ${PYTHON3_DIR}) | ||
set(ENV{PYTHON_BIN_PATH} "${PYTHON3}") | ||
|
||
function(tensorflow_try_remove_recurse_wait PATH_TO_REMOVE) | ||
file(REMOVE_RECURSE ${PATH_TO_REMOVE}) | ||
if (EXISTS "${PATH_TO_REMOVE}") | ||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 5) | ||
file(REMOVE_RECURSE ${PATH_TO_REMOVE}) | ||
endif() | ||
endfunction() | ||
|
||
# we currently only support the release version | ||
tensorflow_try_remove_recurse_wait(${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) | ||
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) | ||
file(GLOB SOURCES ${SOURCE_PATH}/*) | ||
file(COPY ${SOURCES} DESTINATION ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) | ||
|
||
if(CMAKE_HOST_WIN32) | ||
vcpkg_acquire_msys(MSYS_ROOT PACKAGES unzip patch diffutils git) | ||
set(BASH ${MSYS_ROOT}/usr/bin/bash.exe) | ||
set(ENV{BAZEL_SH} ${MSYS_ROOT}/usr/bin/bash.exe) | ||
|
||
set(ENV{BAZEL_VS} $ENV{VSInstallDir}) | ||
set(ENV{BAZEL_VC} $ENV{VCInstallDir}) | ||
endif() | ||
|
||
# tensorflow has long file names, which will not work on windows | ||
set(ENV{TEST_TMPDIR} ${CURRENT_BUILDTREES_DIR}/../.bzl) | ||
|
||
set(ENV{USE_DEFAULT_PYTHON_LIB_PATH} 1) | ||
set(ENV{TF_NEED_KAFKA} 0) | ||
set(ENV{TF_NEED_OPENCL_SYCL} 0) | ||
set(ENV{TF_NEED_AWS} 0) | ||
set(ENV{TF_NEED_GCP} 0) | ||
set(ENV{TF_NEED_HDFS} 0) | ||
set(ENV{TF_NEED_S3} 0) | ||
set(ENV{TF_ENABLE_XLA} 0) | ||
set(ENV{TF_NEED_GDR} 0) | ||
set(ENV{TF_NEED_VERBS} 0) | ||
set(ENV{TF_NEED_OPENCL} 0) | ||
set(ENV{TF_NEED_MPI} 0) | ||
set(ENV{TF_NEED_TENSORRT} 0) | ||
set(ENV{TF_NEED_NGRAPH} 0) | ||
set(ENV{TF_NEED_IGNITE} 0) | ||
set(ENV{TF_NEED_ROCM} 0) | ||
set(ENV{TF_SET_ANDROID_WORKSPACE} 0) | ||
set(ENV{TF_DOWNLOAD_CLANG} 0) | ||
set(ENV{TF_NCCL_VERSION} 2.3) | ||
set(ENV{NCCL_INSTALL_PATH} "") | ||
set(ENV{CC_OPT_FLAGS} "/arch:AVX") | ||
set(ENV{TF_NEED_CUDA} 0) | ||
|
||
message(STATUS "Configuring TensorFlow") | ||
|
||
vcpkg_execute_required_process( | ||
COMMAND ${PYTHON3} ${SOURCE_PATH}/configure.py | ||
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel | ||
LOGNAME config-${TARGET_TRIPLET}-rel | ||
) | ||
message(STATUS "Warning: Building TensorFlow can take an hour or more.") | ||
|
||
if(CMAKE_HOST_WIN32) | ||
vcpkg_execute_build_process( | ||
COMMAND ${BASH} --noprofile --norc -c "${BAZEL} build --verbose_failures -c opt --python_path=${PYTHON3} --incompatible_disable_deprecated_attr_params=false --define=no_tensorflow_py_deps=true ///tensorflow:libtensorflow_cc.so ///tensorflow:install_headers" | ||
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel | ||
LOGNAME build-${TARGET_TRIPLET}-rel | ||
) | ||
else() | ||
vcpkg_execute_build_process( | ||
COMMAND ${BAZEL} build --verbose_failures -c opt --python_path=${PYTHON3} --incompatible_disable_deprecated_attr_params=false --define=no_tensorflow_py_deps=true //tensorflow:libtensorflow_cc.so //tensorflow:install_headers | ||
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel | ||
LOGNAME build-${TARGET_TRIPLET}-rel | ||
) | ||
endif() | ||
|
||
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-genfiles/tensorflow/include/ DESTINATION ${CURRENT_PACKAGES_DIR}/include/tensorflow-external) | ||
|
||
if(CMAKE_HOST_WIN32) | ||
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/libtensorflow_cc.so.1.14.0 DESTINATION ${CURRENT_PACKAGES_DIR}/lib) | ||
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/libtensorflow_cc.so.1.14.0.if.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib) | ||
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/libtensorflow_cc.so.1.14.0 DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) | ||
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/libtensorflow_cc.so.1.14.0.if.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) | ||
else() | ||
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/libtensorflow_cc.so.1.14.0 DESTINATION ${CURRENT_PACKAGES_DIR}/lib) | ||
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/libtensorflow_framework.so.1.14.0 DESTINATION ${CURRENT_PACKAGES_DIR}/lib) | ||
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/libtensorflow_cc.so.1.14.0 DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) | ||
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/bazel-bin/tensorflow/libtensorflow_framework.so.1.14.0 DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) | ||
endif() | ||
|
||
file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc) | ||
file(RENAME ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc/LICENSE ${CURRENT_PACKAGES_DIR}/share/tensorflow-cc/copyright) | ||
|
||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/TensorflowCCConfig.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/unofficial-tensorflow-cc) | ||
file(RENAME ${CURRENT_PACKAGES_DIR}/share/unofficial-tensorflow-cc/TensorflowCCConfig.cmake ${CURRENT_PACKAGES_DIR}/share/unofficial-tensorflow-cc/unofficial-tensorflow-cc-config.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters