aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/cmake/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/contrib/cmake/CMakeLists.txt')
-rw-r--r--tensorflow/contrib/cmake/CMakeLists.txt147
1 files changed, 119 insertions, 28 deletions
diff --git a/tensorflow/contrib/cmake/CMakeLists.txt b/tensorflow/contrib/cmake/CMakeLists.txt
index 8744fc492f..77a3fc0c83 100644
--- a/tensorflow/contrib/cmake/CMakeLists.txt
+++ b/tensorflow/contrib/cmake/CMakeLists.txt
@@ -34,13 +34,41 @@ option(tensorflow_BUILD_SHARED_LIB "Build TensorFlow as a shared library" OFF)
option(tensorflow_OPTIMIZE_FOR_NATIVE_ARCH "Enable compiler optimizations for the native processor architecture (if available)" ON)
option(tensorflow_WIN_CPU_SIMD_OPTIONS "Enables CPU SIMD instructions")
option(tensorflow_ENABLE_SNAPPY_SUPPORT "Enable SNAPPY compression support" ON)
+if(HAIKU)
+ option(tensorflow_ENABLE_POSITION_INDEPENDENT_CODE "Enable PIE support" OFF)
+else()
+ option(tensorflow_ENABLE_POSITION_INDEPENDENT_CODE "Enable PIE support" ON)
+endif()
+
if (NOT WIN32)
# Threads: defines CMAKE_THREAD_LIBS_INIT and adds -pthread compile option
# for targets that link ${CMAKE_THREAD_LIBS_INIT}.
find_package (Threads)
+
+ option(tensorflow_PATH_STATIC_LIB "Additional library search path for libcudnn_static.a, libnccl_static.a, libculibos.a" /usr/local/cuda/lib64/)
+ option(tensorflow_CUDNN_INCLUDE "cudnn.h header install path" /usr/include/)
+ if (NOT tensorflow_CUDNN_INCLUDE)
+ # option's default value is OFF. Fill it with real default values
+ set(tensorflow_CUDNN_INCLUDE /usr/include)
+ endif (NOT tensorflow_CUDNN_INCLUDE)
+ option(tensorflow_PATH_CUDNN_STATIC_LIB "Override PATH_STATIC_LIB for libcudnn_static.a" ${tensorflow_PATH_STATIC_LIB})
+ option(tensorflow_PATH_NCCL_STATIC_LIB "Override PATH_STATIC_LIB for libnccl_static.a" ${tensorflow_PATH_STATIC_LIB})
+ option(tensorflow_CUDA_LIBRARY_PATH "Designate the default CUDA library paths" /usr/local/cuda/lib64)
+ if (NOT tensorflow_CUDA_LIBRARY_PATH)
+ # option's default value is OFF. Fill it with real default values
+ set(tensorflow_CUDA_LIBRARY_PATH /usr/local/cuda/lib64)
+ endif (NOT tensorflow_CUDA_LIBRARY_PATH)
endif()
+if (WIN32)
+ set(BOOL_WIN32 ON)
+else (WIN32)
+ set(BOOL_WIN32 OFF)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
+endif (WIN32)
+
# [CLEANUP] Remove when done
# For debugging
function(SHOW_VARIABLES)
@@ -58,7 +86,12 @@ set (DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/downloads"
CACHE PATH "Location where external projects will be downloaded.")
mark_as_advanced(DOWNLOAD_LOCATION)
-set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+if (tensorflow_ENABLE_POSITION_INDEPENDENT_CODE)
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+else()
+ set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
+endif()
+
add_definitions(-DEIGEN_AVOID_STL_ARRAY)
if(WIN32)
add_definitions(-DNOMINMAX -D_WIN32_WINNT=0x0A00 -DLANG_CXX11 -DCOMPILER_MSVC)
@@ -217,20 +250,35 @@ endif()
if(UNIX)
list(APPEND tensorflow_EXTERNAL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
endif()
+if(HAIKU)
+ list(APPEND tensorflow_EXTERNAL_LIBRARIES network)
+endif()
if (tensorflow_ENABLE_GPU)
+ if (NOT WIN32)
+ # Default install paths for cuda libraries in Linux
+ # In some Linux distros, find_package(CUDA) seems to require CMAKE_LIBRARY_PATH to include cuda-lib paths
+ list(APPEND CMAKE_LIBRARY_PATH "${tensorflow_CUDA_LIBRARY_PATH}")
+ list(APPEND CMAKE_LIBRARY_PATH "${tensorflow_CUDA_LIBRARY_PATH}/stubs")
+ endif (NOT WIN32)
+
+ find_package(CUDA 8.0 REQUIRED)
+
+ # by default we assume compute cabability 3.5 and 5.2. If you change this change it in
+ # CUDA_NVCC_FLAGS and cuda_config.h below
+ set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_30,code=\"sm_30,compute_30\";-gencode arch=compute_35,code=\"sm_35,compute_35\";-gencode arch=compute_52,code=\"sm_52,compute_52\")
+ set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};--include-path ${PROJECT_BINARY_DIR}/$\{build_configuration\};--expt-relaxed-constexpr)
+ set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-ftz=true) # Flush denormals to zero
+ set(CUDA_INCLUDE ${CUDA_TOOLKIT_TARGET_DIR} ${CUDA_TOOLKIT_TARGET_DIR}/extras/CUPTI/include)
+ include_directories(${CUDA_INCLUDE})
if (WIN32)
- find_package(CUDA 8.0 REQUIRED)
-
- # by default we assume compute cabability 3.5 and 5.2. If you change this change it in
- # CUDA_NVCC_FLAGS and cuda_config.h below
- set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_30,code=\"sm_30,compute_30\";-gencode arch=compute_35,code=\"sm_35,compute_35\";-gencode arch=compute_52,code=\"sm_52,compute_52\")
- set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};--include-path ${PROJECT_BINARY_DIR}/$\{build_configuration\};--expt-relaxed-constexpr)
- set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-ftz=true) # Flush denormals to zero
- set(CUDA_INCLUDE ${CUDA_TOOLKIT_TARGET_DIR} ${CUDA_TOOLKIT_TARGET_DIR}/extras/CUPTI/include)
- include_directories(${CUDA_INCLUDE})
add_definitions(-DGOOGLE_CUDA=1 -DTF_EXTRA_CUDA_CAPABILITIES=3.0,3.5,5.2)
+ else (WIN32)
+ # Without these double quotes, cmake in Linux makes it "-DTF_EXTRA_CUDA_CAPABILITIES=3.0, -D3.5, -D5.2" for cc, which incurs build breaks
+ add_definitions(-DGOOGLE_CUDA=1 -D"TF_EXTRA_CUDA_CAPABILITIES=3.0,3.5,5.2")
+ endif (WIN32)
+ if (WIN32)
# add cudnn
if(NOT CUDNN_HOME)
set(CUDNN_HOME ${CUDA_TOOLKIT_TARGET_DIR})
@@ -238,18 +286,48 @@ if (tensorflow_ENABLE_GPU)
include_directories(${CUDNN_HOME})
set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_CUFFT_LIBRARIES}
${CUDA_curand_LIBRARY} ${CUDA_cupti_LIBRARY} ${CUDA_cusolver_LIBRARY} ${CUDNN_HOME}/lib/x64/cudnn.lib)
+ else (WIN32)
+ set(CUDNN_INCLUDE "${tensorflow_CUDNN_INCLUDE}")
- # create cuda_config.h
- FILE(WRITE ${tensorflow_source_dir}/third_party/gpus/cuda/cuda_config.h
- "#ifndef CUDA_CUDA_CONFIG_H_\n"
- "#define CUDA_CUDA_CONFIG_H_\n"
- "#define TF_CUDA_CAPABILITIES CudaVersion(\"3.0\"),CudaVersion(\"3.5\"),CudaVersion(\"5.2\")\n"
- "#define TF_CUDA_VERSION \"64_80\"\n"
- "#define TF_CUDNN_VERSION \"64_6\"\n"
- "#define TF_CUDA_TOOLKIT_PATH \"${CUDA_TOOLKIT_ROOT_DIR}\"\n"
- "#endif // CUDA_CUDA_CONFIG_H_\n"
- )
+ find_library(nccl_STATIC_LIBRARY NAMES libnccl_static.a PATHS ${tensorflow_PATH_NCCL_STATIC_LIB} ${CUDA_TOOLKIT_ROOT_DIR})
+ if (NOT nccl_STATIC_LIBRARY)
+ message(FATAL_ERROR "NCCL is required for GPU-build")
+ else (NOT nccl_STATIC_LIBRARY)
+ message("nccl-static: ${nccl_STATIC_LIBRARY}")
+ # something like /usr/lib64/libnccl_static.a
+ endif (NOT nccl_STATIC_LIBRARY)
+
+ find_library(cudnn_STATIC_LIBRARY NAMES libcudnn_static.a PATHS ${tensorflow_PATH_CUDNN_STATIC_LIB} ${CUDA_TOOLKIT_ROOT_DIR})
+ if (NOT cudnn_STATIC_LIBRARY)
+ message(FATAL_ERROR "CUDNN is required for GPU-build")
+ else (NOT cudnn_STATIC_LIBRARY)
+ message("cudnn-static: ${cudnn_STATIC_LIBRARY}")
+ endif (NOT cudnn_STATIC_LIBRARY)
+
+ find_library(culibos_STATIC_LIBRARY NAMES libculibos.a PATHS ${tensorflow_PATH_STATIC_LIB} ${CUDA_TOOLKIT_ROOT_DIR})
+ if (NOT culibos_STATIC_LIBRARY)
+ message(FATAL_ERROR "CULIBOS is required for GPU-build")
+ else (NOT culibos_STATIC_LIBRARY)
+ message("culibos-static: ${culibos_STATIC_LIBRARY}")
+ endif (NOT culibos_STATIC_LIBRARY)
+
+ include_directories(${CUDNN_INCLUDE})
+ set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_CUFFT_LIBRARIES}
+ ${CUDA_curand_LIBRARY} ${CUDA_cupti_LIBRARY} ${CUDA_cusolver_LIBRARY} ${cudnn_STATIC_LIBRARY} ${culibos_STATIC_LIBRARY} ${nccl_STATIC_LIBRARY})
+ endif (WIN32)
+
+ # create cuda_config.h
+ FILE(WRITE ${tensorflow_source_dir}/third_party/gpus/cuda/cuda_config.h
+ "#ifndef CUDA_CUDA_CONFIG_H_\n"
+ "#define CUDA_CUDA_CONFIG_H_\n"
+ "#define TF_CUDA_CAPABILITIES CudaVersion(\"3.0\"),CudaVersion(\"3.5\"),CudaVersion(\"5.2\")\n"
+ "#define TF_CUDA_VERSION \"64_80\"\n"
+ "#define TF_CUDNN_VERSION \"64_6\"\n"
+ "#define TF_CUDA_TOOLKIT_PATH \"${CUDA_TOOLKIT_ROOT_DIR}\"\n"
+ "#endif // CUDA_CUDA_CONFIG_H_\n"
+ )
+ if (WIN32)
# tf assumes in various places header files to be in cuda/include. On windows the cuda sdk
# installs them under cuda/version/include and to avoid that we need to change tf we copy a
# few files to cuda/include
@@ -261,12 +339,25 @@ if (tensorflow_ENABLE_GPU)
${CUDA_TOOLKIT_TARGET_DIR}/include/cusolverDn.h
DESTINATION ${tensorflow_source_dir}/third_party/gpus/cuda/include
)
- include_directories(${tensorflow_source_dir}/third_party/gpus)
- # add cuda libraries to tensorflow_EXTERNAL_LIBRARIES
- list(APPEND tensorflow_EXTERNAL_LIBRARIES ${CUDA_LIBRARIES})
+ else(WIN32)
+ # Linux has slightly differnt install paths than Windows
+ FILE(COPY
+ ${CUDA_TOOLKIT_TARGET_DIR}/include/cuda.h ${CUDA_TOOLKIT_TARGET_DIR}/include/cuComplex.h
+ ${CUDA_TOOLKIT_TARGET_DIR}/include/cublas_v2.h ${CUDNN_INCLUDE}/cudnn.h
+ ${CUDA_TOOLKIT_TARGET_DIR}/include/cufft.h ${CUDA_TOOLKIT_TARGET_DIR}/include/curand.h
+ ${CUDA_TOOLKIT_TARGET_DIR}/include/cuda_runtime_api.h
+ ${CUDA_TOOLKIT_TARGET_DIR}/include/cusolverDn.h
+ DESTINATION ${tensorflow_source_dir}/third_party/gpus/cuda/include
+ )
+ endif(WIN32)
- # NOTE(mrry): Update these flags when the version of CUDA or cuDNN used
- # in the default build is upgraded.
+ include_directories(${tensorflow_source_dir}/third_party/gpus)
+ # add cuda libraries to tensorflow_EXTERNAL_LIBRARIES
+ list(APPEND tensorflow_EXTERNAL_LIBRARIES ${CUDA_LIBRARIES})
+
+ # NOTE(mrry): Update these flags when the version of CUDA or cuDNN used
+ # in the default build is upgraded.
+ if(WIN32)
set(tensorflow_BUILD_INFO_FLAGS --build_config cuda --key_value
msvcp_dll_name=msvcp140.dll
cudart_dll_name=cudart64_80.dll
@@ -275,7 +366,9 @@ if (tensorflow_ENABLE_GPU)
cudnn_dll_name=cudnn64_6.dll
cudnn_version_number=6)
else(WIN32)
- message(FATAL_ERROR "CMake GPU build is currently only supported on Windows.")
+ set(tensorflow_BUILD_INFO_FLAGS --build_config cuda --key_value
+ cuda_version_number=8.0
+ cudnn_version_number=6)
endif(WIN32)
else(tensorflow_ENABLE_GPU)
set(tensorflow_BUILD_INFO_FLAGS --build_config cpu --key_value
@@ -293,9 +386,7 @@ include(tf_core_framework.cmake)
# NOTE: Disabled until issue #3996 is fixed.
# include(tf_stream_executor.cmake)
if (tensorflow_ENABLE_GPU)
- if (WIN32)
include(tf_stream_executor.cmake)
- endif()
endif()
include(tf_core_cpu.cmake)