diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index 363bf88fedfa3d8021a4c808c38359e90022af3c..544b67604ff47cb48649b84ec769cec50529229c 100644 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -135,10 +135,13 @@ copy(inference_lib_dist SRCS ${THREADPOOL_INCLUDE_DIR}/ThreadPool.h DSTS ${dst_dir}) -set(dst_dir "${FLUID_INFERENCE_INSTALL_DIR}/third_party/cudaerror/data") -copy(inference_lib_dist - SRCS ${cudaerror_INCLUDE_DIR} - DSTS ${dst_dir}) +# Only GPU need cudaErrorMessage.pb +IF(WITH_GPU) + set(dst_dir "${FLUID_INFERENCE_INSTALL_DIR}/third_party/cudaerror/data") + copy(inference_lib_dist + SRCS ${cudaerror_INCLUDE_DIR} + DSTS ${dst_dir}) +ENDIF() # CMakeCache Info copy(inference_lib_dist diff --git a/cmake/third_party.cmake b/cmake/third_party.cmake index 8a4f54300e9c2e57550b73e85ec6dc381ec54758..be536b2eefbb123d73ec6f8d17c3d22e5aca2cfc 100644 --- a/cmake/third_party.cmake +++ b/cmake/third_party.cmake @@ -107,12 +107,11 @@ ENDMACRO() # 1. URL: The download url of 3rd dependencies # 2. NAME: The name of file, that determin the dirname # -MACRO(file_download_and_uncompress URL NAME) +FUNCTION(file_download_and_uncompress URL NAME) MESSAGE(STATUS "Download dependence[${NAME}] from ${URL}") - SET(EXTERNAL_PROJECT_NAME "extern_download_${NAME}") - SET(${NAME}_INCLUDE_DIR ${THIRD_PARTY_PATH}/${NAME}/data) + SET(${NAME}_INCLUDE_DIR ${THIRD_PARTY_PATH}/${NAME}/data PARENT_SCOPE) ExternalProject_Add( - ${EXTERNAL_PROJECT_NAME} + extern_download_${NAME} ${EXTERNAL_PROJECT_LOG_ARGS} PREFIX ${THIRD_PARTY_PATH}/${NAME} URL ${URL} @@ -124,8 +123,8 @@ MACRO(file_download_and_uncompress URL NAME) UPDATE_COMMAND "" INSTALL_COMMAND "" ) - list(APPEND third_party_deps ${EXTERNAL_PROJECT_NAME}) -ENDMACRO() + set(third_party_deps ${third_party_deps} extern_download_${NAME} PARENT_SCOPE) +ENDFUNCTION() # Correction of flags on different Platform(WIN/MAC) and Print Warning Message @@ -209,10 +208,6 @@ include(external/warpctc) # download, build, install warpctc list(APPEND third_party_deps extern_eigen3 extern_gflags extern_glog extern_boost extern_xxhash) list(APPEND third_party_deps extern_zlib extern_dlpack extern_warpctc extern_threadpool) -# download file -set(CUDAERROR_URL "http://paddlepaddledeps.bj.bcebos.com/cudaErrorMessage.tar.gz" CACHE STRING "" FORCE) -file_download_and_uncompress(${CUDAERROR_URL} "cudaerror") - if(WITH_AMD_GPU) include(external/rocprim) # download, build, install rocprim list(APPEND third_party_deps extern_rocprim) @@ -250,6 +245,9 @@ ENDIF() if(WITH_GPU) include(external/cub) # download cub list(APPEND third_party_deps extern_cub) + + set(CUDAERROR_URL "http://paddlepaddledeps.bj.bcebos.com/cudaErrorMessage.tar.gz" CACHE STRING "" FORCE) + file_download_and_uncompress(${CUDAERROR_URL} "cudaerror") # download file cudaErrorMessage endif(WITH_GPU) if(WITH_PSLIB) diff --git a/paddle/fluid/platform/CMakeLists.txt b/paddle/fluid/platform/CMakeLists.txt index b8fd6fe0f82b1efc26abb2dcced23934f5623f9f..c3ad4f61dc4457ac48b22b20062443341298cf0a 100644 --- a/paddle/fluid/platform/CMakeLists.txt +++ b/paddle/fluid/platform/CMakeLists.txt @@ -1,6 +1,8 @@ proto_library(profiler_proto SRCS profiler.proto DEPS framework_proto simple_threadpool) proto_library(error_codes_proto SRCS error_codes.proto) -proto_library(cuda_error_proto SRCS cuda_error.proto) +if(WITH_GPU) + proto_library(cuda_error_proto SRCS cuda_error.proto) +endif(WITH_GPU) if (WITH_PYTHON) py_proto_compile(profiler_py_proto SRCS profiler.proto) @@ -28,7 +30,11 @@ cc_library(flags SRCS flags.cc DEPS gflags) cc_library(errors SRCS errors.cc DEPS error_codes_proto) cc_test(errors_test SRCS errors_test.cc DEPS errors enforce) -cc_library(enforce INTERFACE SRCS enforce.cc DEPS flags errors cuda_error_proto boost) +set(enforce_deps flags errors boost) +if(WITH_GPU) + set(enforce_deps ${enforce_deps} cuda_error_proto) +endif() +cc_library(enforce INTERFACE SRCS enforce.cc DEPS ${enforce_deps}) cc_test(enforce_test SRCS enforce_test.cc DEPS stringpiece enforce) set(CPU_INFO_DEPS gflags glog enforce) diff --git a/paddle/fluid/platform/enforce.h b/paddle/fluid/platform/enforce.h index e00c31deb2de553b59f6daefadbea4036fab8ee5..0922fcca9188b0d8eeb5096539a77976fdc41eae 100644 --- a/paddle/fluid/platform/enforce.h +++ b/paddle/fluid/platform/enforce.h @@ -31,6 +31,7 @@ limitations under the License. */ #include #include #include +#include "paddle/fluid/platform/cuda_error.pb.h" #endif // PADDLE_WITH_CUDA #include @@ -45,7 +46,6 @@ limitations under the License. */ #define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h #include "glog/logging.h" -#include "paddle/fluid/platform/cuda_error.pb.h" #include "paddle/fluid/platform/errors.h" #include "paddle/fluid/platform/macros.h" #include "paddle/fluid/platform/port.h" diff --git a/python/setup.py.in b/python/setup.py.in index 97a1254607900f598292618d25db9b3df9a189fb..56de5ad86c6e61bebb5f273f58f16800e48a582d 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -357,6 +357,8 @@ headers = ( if '${WITH_MKLDNN}' == 'ON': headers += list(find_files('*', '${MKLDNN_INSTALL_DIR}/include')) # mkldnn +if '${WITH_GPU}' == 'ON': + headers += list(find_files('*.pb', '${cudaerror_INCLUDE_DIR}')) # errorMessage.pb for errormessage class InstallCommand(InstallCommandBase): def finalize_options(self): @@ -416,7 +418,8 @@ class InstallHeaders(Command): def run(self): # only copy third_party/cudaErrorMessage.pb for cudaErrorMessage on mac or windows if os.name == 'nt' or sys.platform == 'darwin': - self.mkdir_and_copy_file('${cudaerror_INCLUDE_DIR}/cudaErrorMessage.pb') + if '${WITH_GPU}' == 'ON': + self.mkdir_and_copy_file('${cudaerror_INCLUDE_DIR}/cudaErrorMessage.pb') return hdrs = self.distribution.headers if not hdrs: