-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Download, build, install External dependencies via cmake #1017
Merged
Merged
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
8a2ceda
Add externel google's dependencies
gangliao 280994f
Add other extern dependencies
gangliao 6cd4b6e
Update external libs
gangliao 662f174
Refine cmake file names
gangliao 62b55cc
Remove paddle internals
gangliao a02ec8c
Refine CMakeLists
gangliao 4b94494
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
gangliao 46cadae
Update external dependencies cmake
gangliao de3c152
Fix glog check type unmatch
gangliao 0b95671
Add external_project_dependencies for targets
gangliao 338dc3e
Fix external denpendencies build order
gangliao 2ffb6db
Fix warpctc header directory
gangliao aee0857
Clean Travis ci and fix bug
gangliao 8acd1ac
Add extern python interp
gangliao 9e7f2b8
Add system configure
gangliao e2d0e09
Update external dependencies
gangliao 642dc35
clean travis ci
gangliao 572d825
Clean cmake
gangliao b090ce3
Fix conflict with develop
gangliao fc47492
Fix merge conflict bug and glog
gangliao 3ecc63a
Add python in travis ci for paddle version command
gangliao 0407902
Add wheel for paddle version command
gangliao 19dc8df
Update travis ci pip
gangliao d0a5ce2
Clean travis ci
gangliao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ build/ | |
.pydevproject | ||
Makefile | ||
.test_env/ | ||
third_party/ | ||
|
||
*~ | ||
bazel-* |
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 |
---|---|---|
|
@@ -4,163 +4,75 @@ project(paddle CXX C) | |
|
||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") | ||
set(PROJ_ROOT ${CMAKE_SOURCE_DIR}) | ||
include(package) | ||
find_package(SWIG 2.0) | ||
find_package(CUDA QUIET) | ||
find_package(Protobuf REQUIRED) | ||
|
||
# Check protobuf library version. | ||
execute_process(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --version | ||
OUTPUT_VARIABLE PROTOBUF_VERSION) | ||
string(REPLACE "libprotoc " "" PROTOBUF_VERSION ${PROTOBUF_VERSION}) | ||
|
||
set(PROTOBUF_3 OFF) | ||
if (${PROTOBUF_VERSION} VERSION_GREATER "3.0.0" OR ${PROTOBUF_VERSION} VERSION_EQUAL "3.0.0") | ||
set(PROTOBUF_3 ON) | ||
endif() | ||
|
||
find_package(PythonLibs 2.7 REQUIRED) | ||
find_package(PythonInterp 2.7 REQUIRED) | ||
find_package(ZLIB REQUIRED) | ||
find_package(NumPy REQUIRED) | ||
find_package(Threads REQUIRED) | ||
find_package(AVX QUIET) | ||
find_package(Glog REQUIRED) | ||
find_package(Gflags REQUIRED) | ||
find_package(GTest) | ||
find_package(Sphinx) | ||
find_package(Doxygen) | ||
include(cblas) | ||
find_program(M4_EXECUTABLE m4) | ||
###################### Configurations ########################### | ||
find_package(CUDA QUIET) | ||
find_package(Git REQUIRED) | ||
find_package(Threads REQUIRED) | ||
|
||
include(simd) | ||
|
||
###################### Configurations ############################ | ||
option(WITH_DSO "Compile PaddlePaddle with dynamic linked libraries" ON) | ||
option(WITH_GPU "Compile PaddlePaddle with gpu" ${CUDA_FOUND}) | ||
option(WITH_DOUBLE "Compile PaddlePaddle with double precision, otherwise use single precision" OFF) | ||
option(WITH_AVX "Compile PaddlePaddle with avx intrinsics" ${AVX_FOUND}) | ||
option(WITH_PYTHON "Compile PaddlePaddle with python interpreter" ON) | ||
option(WITH_STYLE_CHECK "Style Check for PaddlePaddle" ${PYTHONINTERP_FOUND}) | ||
option(WITH_STYLE_CHECK "Style Check for PaddlePaddle" ON) | ||
option(WITH_RDMA "Compile PaddlePaddle with rdma support" OFF) | ||
option(WITH_TIMER "Compile PaddlePaddle use timer" OFF) | ||
option(WITH_PROFILER "Compile PaddlePaddle use gpu profiler" OFF) | ||
option(WITH_TESTING "Compile and run unittest for PaddlePaddle" ${GTEST_FOUND}) | ||
option(WITH_TESTING "Compile and run unittest for PaddlePaddle" ON) | ||
option(WITH_DOC "Compile PaddlePaddle with documentation" OFF) | ||
option(WITH_SWIG_PY "Compile PaddlePaddle with py PaddlePaddle prediction api" ${SWIG_FOUND}) | ||
option(WITH_SWIG_PY "Compile PaddlePaddle with py PaddlePaddle prediction api" ON) | ||
option(ON_TRAVIS "Running test on travis-ci or not." OFF) | ||
option(ON_COVERALLS "Generating code coverage data on coveralls or not." OFF) | ||
option(COVERALLS_UPLOAD "Uploading the generated coveralls json." ON) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CMakeLists 干净很多了 |
||
include(external/zlib) # download, build, install zlib | ||
include(external/gflags) # download, build, install gflags | ||
include(external/glog) # download, build, install glog | ||
include(external/gtest) # download, build, install gtest | ||
include(external/protobuf) # download, build, install protobuf | ||
include(external/openblas) # download, build, install openblas | ||
include(external/python) # download, build, install python | ||
include(external/numpy) # download, build, install numpy | ||
include(external/swig) # download, build, install swig | ||
include(external/warpctc) # download, build, install warpctc | ||
|
||
include(package) # set paddle packages | ||
include(cpplint) # set paddle c++ style | ||
include(ccache) # set ccache for compilation | ||
include(util) # set unittest and link libs | ||
include(rdma) # set rdma libraries | ||
include(flags) # set paddle compile flags | ||
include(cudnn) # set cudnn libraries | ||
include(version) # set PADDLE_VERSION | ||
include(coveralls) # set code coverage | ||
include(python_module) # set python module | ||
|
||
include(check_packages) # check configuration | ||
include(definitions) # add paddle definitions | ||
|
||
include(cpplint) | ||
include(ccache) | ||
if(WITH_RDMA) | ||
include(rdma) | ||
endif() | ||
include(util) | ||
include(flags) | ||
include(cudnn) | ||
include(FindPythonModule) | ||
include(check_packages) | ||
include(swig) | ||
include(coveralls) | ||
|
||
# Set PaddlePaddle version to Git tag name or Git commit ID. | ||
find_package(Git REQUIRED) | ||
# version.cmake will get the current PADDLE_VERSION | ||
include(version) | ||
add_definitions(-DPADDLE_VERSION=${PADDLE_VERSION}) | ||
|
||
if(NOT WITH_GPU) | ||
add_definitions(-DPADDLE_ONLY_CPU) | ||
add_definitions(-DHPPL_STUB_FUNC) | ||
|
||
list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu) | ||
else() | ||
if(${CUDA_VERSION_MAJOR} VERSION_LESS 7) | ||
message(FATAL_ERROR "Paddle need CUDA >= 7.0 to compile") | ||
endif() | ||
|
||
if(NOT CUDNN_FOUND) | ||
message(FATAL_ERROR "Paddle need cudnn to compile") | ||
endif() | ||
|
||
if(WITH_AVX) | ||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler ${AVX_FLAG}") | ||
else(WITH_AVX) | ||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler ${SSE3_FLAG}") | ||
endif(WITH_AVX) | ||
|
||
# Include cuda and cudnn | ||
include_directories(${CUDNN_INCLUDE_DIR}) | ||
include_directories(${CUDA_TOOLKIT_INCLUDE}) | ||
endif(NOT WITH_GPU) | ||
|
||
if(WITH_DSO) | ||
add_definitions(-DPADDLE_USE_DSO) | ||
endif(WITH_DSO) | ||
|
||
if(WITH_DOUBLE) | ||
add_definitions(-DPADDLE_TYPE_DOUBLE) | ||
set(ACCURACY double) | ||
else(WITH_DOUBLE) | ||
set(ACCURACY float) | ||
endif(WITH_DOUBLE) | ||
|
||
if(NOT WITH_TIMER) | ||
add_definitions(-DPADDLE_DISABLE_TIMER) | ||
endif(NOT WITH_TIMER) | ||
|
||
if(NOT WITH_PROFILER) | ||
add_definitions(-DPADDLE_DISABLE_PROFILER) | ||
endif(NOT WITH_PROFILER) | ||
|
||
if(WITH_AVX) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AVX_FLAG}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AVX_FLAG}") | ||
else(WITH_AVX) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SSE3_FLAG}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SSE3_FLAG}") | ||
endif(WITH_AVX) | ||
|
||
if(WITH_PYTHON) | ||
include_directories(${PYTHON_INCLUDE_DIR}) | ||
include_directories(${PYTHON_NUMPY_INCLUDE_DIR}) | ||
else(WITH_PYTHON) | ||
add_definitions(-DPADDLE_NO_PYTHON) | ||
endif(WITH_PYTHON) | ||
|
||
if(WITH_RDMA) | ||
include_directories("${RDMA_INC_DIR}") | ||
else(WITH_RDMA) | ||
add_definitions(-DPADDLE_DISABLE_RDMA) | ||
endif(WITH_RDMA) | ||
|
||
# glog | ||
include_directories(${LIBGLOG_INCLUDE_DIR}) | ||
|
||
#gflags | ||
add_definitions(-DGFLAGS_NS=${GFLAGS_NAMESPACE}) | ||
include_directories(${GFLAGS_INCLUDE_DIRS}) | ||
|
||
if(WITH_TESTING) | ||
enable_testing() | ||
include_directories(${GTEST_INCLUDE_DIRS}) | ||
endif() | ||
|
||
include_directories("${CBLAS_INC_DIR}") | ||
include_directories("${PROJ_ROOT}") | ||
include_directories("${PROJ_ROOT}/paddle/cuda/include") | ||
include_directories(${PROTOBUF_INCLUDE_DIRS}) | ||
include_directories("${CMAKE_CURRENT_BINARY_DIR}/proto") | ||
if(EXISTS "${PROJ_ROOT}/paddle/internals/CMakeLists.txt") | ||
set(PADDLE_WITH_INTERNAL ON) | ||
include(paddle/internals/CMakeLists.txt) | ||
else() | ||
set(PADDLE_WITH_INTERNAL OFF) | ||
set(INTERNAL_PROTO_PATH "") | ||
endif() | ||
|
||
set(EXTERNAL_LIBS | ||
# have not include gtest here. | ||
${GFLAGS_LIBRARIES} | ||
${GLOG_LIBRARIES} | ||
${CBLAS_LIBRARIES} | ||
${PROTOBUF_LIBRARIES} | ||
${WARPCTC_LIBRARIES} | ||
${ZLIB_LIBRARIES} | ||
) | ||
|
||
add_subdirectory(proto) | ||
add_subdirectory(paddle) | ||
add_subdirectory(python) | ||
|
||
if(WITH_DOC) | ||
add_subdirectory(doc) | ||
endif() |
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
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,62 @@ | ||
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. | ||
# | ||
# 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. | ||
|
||
if(WITH_DSO) | ||
add_definitions(-DPADDLE_USE_DSO) | ||
endif(WITH_DSO) | ||
|
||
if(WITH_DOUBLE) | ||
add_definitions(-DPADDLE_TYPE_DOUBLE) | ||
endif(WITH_DOUBLE) | ||
|
||
if(NOT WITH_TIMER) | ||
add_definitions(-DPADDLE_DISABLE_TIMER) | ||
endif(NOT WITH_TIMER) | ||
|
||
if(NOT WITH_PROFILER) | ||
add_definitions(-DPADDLE_DISABLE_PROFILER) | ||
endif(NOT WITH_PROFILER) | ||
|
||
if(NOT WITH_GPU) | ||
add_definitions(-DPADDLE_ONLY_CPU) | ||
add_definitions(-DHPPL_STUB_FUNC) | ||
|
||
list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu) | ||
else() | ||
if(${CUDA_VERSION_MAJOR} VERSION_LESS 7) | ||
message(FATAL_ERROR "Paddle need CUDA >= 7.0 to compile") | ||
endif() | ||
|
||
if(NOT CUDNN_FOUND) | ||
message(FATAL_ERROR "Paddle need cudnn to compile") | ||
endif() | ||
|
||
if(WITH_AVX) | ||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler ${AVX_FLAG}") | ||
else(WITH_AVX) | ||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler ${SSE3_FLAG}") | ||
endif(WITH_AVX) | ||
|
||
# Include cuda and cudnn | ||
include_directories(${CUDNN_INCLUDE_DIR}) | ||
include_directories(${CUDA_TOOLKIT_INCLUDE}) | ||
endif(NOT WITH_GPU) | ||
|
||
if(WITH_AVX) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AVX_FLAG}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AVX_FLAG}") | ||
else(WITH_AVX) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SSE3_FLAG}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SSE3_FLAG}") | ||
endif(WITH_AVX) |
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,39 @@ | ||
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. | ||
# | ||
# 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. | ||
|
||
INCLUDE(ExternalProject) | ||
|
||
SET(GFLAGS_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags) | ||
SET(GFLAGS_INSTALL_DIR ${PROJECT_BINARY_DIR}/gflags) | ||
|
||
ExternalProject_Add( | ||
gflags | ||
GIT_REPOSITORY "https://github.com/gflags/gflags.git" | ||
PREFIX ${GFLAGS_SOURCES_DIR} | ||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${GFLAGS_INSTALL_DIR} | ||
CMAKE_ARGS -DBUILD_TESTING=OFF | ||
LOG_DOWNLOAD =ON | ||
UPDATE_COMMAND "" | ||
) | ||
|
||
SET(GFLAGS_INCLUDE_DIR "${GFLAGS_INSTALL_DIR}/include" CACHE PATH "gflags include directory." FORCE) | ||
INCLUDE_DIRECTORIES(${GFLAGS_INCLUDE_DIR}) | ||
|
||
IF(WIN32) | ||
set(GFLAGS_LIBRARIES "${GFLAGS_INSTALL_DIR}/lib/gflags.lib" CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE) | ||
ELSE(WIN32) | ||
set(GFLAGS_LIBRARIES "${GFLAGS_INSTALL_DIR}/lib/libgflags.a" CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE) | ||
ENDIF(WIN32) | ||
|
||
LIST(APPEND external_project_dependencies gflags) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runtime avx搞定之后的话,simd也可以去掉了