From 49d7bd38448b7b876a08af8c8afb1062d9469f14 Mon Sep 17 00:00:00 2001 From: Qi Li Date: Tue, 19 Oct 2021 15:56:57 +0800 Subject: [PATCH] [NPU] update inference cmake, test=develop (#36505) * [NPU] update inference cmake, test=develop * address review comments, test=develop * fix compile error when WITH_ASCEND_CXX11 ON, test=develop --- cmake/external/ascend.cmake | 32 +++++++++++++++++++++++++++ cmake/inference_lib.cmake | 9 +++++++- cmake/miopen.cmake | 2 -- paddle/fluid/platform/resource_pool.h | 1 + 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/cmake/external/ascend.cmake b/cmake/external/ascend.cmake index 414b2a54be..b643923cdd 100644 --- a/cmake/external/ascend.cmake +++ b/cmake/external/ascend.cmake @@ -85,5 +85,37 @@ if(WITH_ASCEND_CL) ADD_LIBRARY(acl_op_compiler SHARED IMPORTED GLOBAL) SET_PROPERTY(TARGET acl_op_compiler PROPERTY IMPORTED_LOCATION ${acl_op_compiler_lib}) add_custom_target(extern_ascend_cl DEPENDS ascendcl acl_op_compiler) +endif() +if (WITH_ASCEND_CL) +macro(find_ascend_toolkit_version ascend_toolkit_version_info) + file(READ ${ascend_toolkit_version_info} ASCEND_TOOLKIT_VERSION_CONTENTS) + string(REGEX MATCH "version=([0-9]+\.[0-9]+\.[0-9]+\.[a-z]*[0-9]*)" ASCEND_TOOLKIT_VERSION "${ASCEND_TOOLKIT_VERSION_CONTENTS}") + string(REGEX REPLACE "version=([0-9]+\.[0-9]+\.[0-9]+\.[a-z]*[0-9]*)" "\\1" ASCEND_TOOLKIT_VERSION "${ASCEND_TOOLKIT_VERSION}") + if(NOT ASCEND_TOOLKIT_VERSION) + set(ASCEND_TOOLKIT_VERSION "???") + else() + message(STATUS "Current Ascend Toolkit version is ${ASCEND_TOOLKIT_VERSION}") + endif() +endmacro() + +macro(find_ascend_driver_version ascend_driver_version_info) + file(READ ${ascend_driver_version_info} ASCEND_DRIVER_VERSION_CONTENTS) + string(REGEX MATCH "Version=([0-9]+\.[0-9]+\.[0-9]+)" ASCEND_DRIVER_VERSION "${ASCEND_DRIVER_VERSION_CONTENTS}") + string(REGEX REPLACE "Version=([0-9]+\.[0-9]+\.[0-9]+)" "\\1" ASCEND_DRIVER_VERSION "${ASCEND_DRIVER_VERSION}") + if(NOT ASCEND_DRIVER_VERSION) + set(ASCEND_DRIVER_VERSION "???") + else() + message(STATUS "Current Ascend Driver version is ${ASCEND_DRIVER_VERSION}") + endif() +endmacro() + +if (WITH_ARM) + set(ASCEND_TOOLKIT_DIR ${ASCEND_DIR}/ascend-toolkit/latest/arm64-linux) +else() + set(ASCEND_TOOLKIT_DIR ${ASCEND_DIR}/ascend-toolkit/latest/x86_64-linux) endif() + +find_ascend_toolkit_version(${ASCEND_TOOLKIT_DIR}/ascend_toolkit_install.info) +find_ascend_driver_version(${ASCEND_DIR}/driver/version.info) +endif() \ No newline at end of file diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index cb2ed614d3..5ffbf15c96 100644 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -353,7 +353,9 @@ function(version version_file) "WITH_MKL: ${WITH_MKL}\n" "WITH_MKLDNN: ${WITH_MKLDNN}\n" "WITH_GPU: ${WITH_GPU}\n" - "WITH_ROCM: ${WITH_ROCM}\n") + "WITH_ROCM: ${WITH_ROCM}\n" + "WITH_ASCEND_CL: ${WITH_ASCEND_CL}\n" + "WITH_ASCEND_CXX11: ${WITH_ASCEND_CXX11}\n") if(WITH_GPU) file(APPEND ${version_file} "CUDA version: ${CUDA_VERSION}\n" @@ -364,6 +366,11 @@ function(version version_file) "HIP version: ${HIP_VERSION}\n" "MIOpen version: v${MIOPEN_MAJOR_VERSION}.${MIOPEN_MINOR_VERSION}\n") endif() + if(WITH_ASCEND_CL) + file(APPEND ${version_file} + "Ascend Toolkit version: ${ASCEND_TOOLKIT_VERSION}\n" + "Ascend Driver version: ${ASCEND_DRIVER_VERSION}\n") + endif() file(APPEND ${version_file} "CXX compiler version: ${CMAKE_CXX_COMPILER_VERSION}\n") if(TENSORRT_FOUND) file(APPEND ${version_file} diff --git a/cmake/miopen.cmake b/cmake/miopen.cmake index f482f423dc..493c37955f 100644 --- a/cmake/miopen.cmake +++ b/cmake/miopen.cmake @@ -15,8 +15,6 @@ find_path(MIOPEN_INCLUDE_DIR "miopen/miopen.h" NO_DEFAULT_PATH ) -get_filename_component(__libpath_hist ${CUDA_CUDART_LIBRARY} PATH) - find_library(MIOPEN_LIBRARY NAMES "libMIOpen.so" PATHS ${MIOPEN_ROOT} ${MIOPEN_ROOT}/lib ${MIOPEN_ROOT}/lib64 ${__libpath_hist} $ENV{MIOPEN_ROOT} $ENV{MIOPEN_ROOT}/lib $ENV{MIOPEN_ROOT}/lib64 diff --git a/paddle/fluid/platform/resource_pool.h b/paddle/fluid/platform/resource_pool.h index 3603c0f24f..f01d006d5b 100644 --- a/paddle/fluid/platform/resource_pool.h +++ b/paddle/fluid/platform/resource_pool.h @@ -16,6 +16,7 @@ #include #include +#include #include #include #include -- GitLab