From 22b5c07a7d4d1e6b0cb645a1efac78717f6f30d2 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Wed, 28 Feb 2018 18:12:47 +0800 Subject: [PATCH] Fix the compilation on CUDA 9.1/GCC 5.3 * Make CUPTI_LIB_PATH not passing by macro. * Add missing header --- cmake/configure.cmake | 3 --- paddle/fluid/platform/device_tracer.cc | 1 + paddle/fluid/platform/dynload/CMakeLists.txt | 1 + .../fluid/platform/dynload/cupti_lib_path.h.in | 17 +++++++++++++++++ paddle/fluid/platform/dynload/dynamic_loader.cc | 4 ++-- 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 paddle/fluid/platform/dynload/cupti_lib_path.h.in diff --git a/cmake/configure.cmake b/cmake/configure.cmake index 7730453fc92..0f76f552705 100644 --- a/cmake/configure.cmake +++ b/cmake/configure.cmake @@ -59,7 +59,6 @@ endif(NOT WITH_GOLANG) if(NOT WITH_GPU) add_definitions(-DHPPL_STUB_FUNC) - add_definitions("-DCUPTI_LIB_PATH=\"\"") list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu) else() @@ -77,9 +76,7 @@ else() if(CUPTI_FOUND) include_directories(${CUPTI_INCLUDE_DIR}) add_definitions(-DPADDLE_WITH_CUPTI) - add_definitions("-DCUPTI_LIB_PATH=\"${CUPTI_LIBRARY_PATH}\"") else() - add_definitions("-DCUPTI_LIB_PATH=\"\"") message(STATUS "Cannot find CUPTI, GPU Profiling is incorrect.") endif() set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler ${SIMD_FLAG}") diff --git a/paddle/fluid/platform/device_tracer.cc b/paddle/fluid/platform/device_tracer.cc index 87bbdfa5fd5..d465520bd7c 100644 --- a/paddle/fluid/platform/device_tracer.cc +++ b/paddle/fluid/platform/device_tracer.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/platform/device_tracer.h" #include #include +#include #include "glog/logging.h" #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/string/printf.h" diff --git a/paddle/fluid/platform/dynload/CMakeLists.txt b/paddle/fluid/platform/dynload/CMakeLists.txt index 567c137a55e..84dac2937de 100644 --- a/paddle/fluid/platform/dynload/CMakeLists.txt +++ b/paddle/fluid/platform/dynload/CMakeLists.txt @@ -1,6 +1,7 @@ cc_library(dynamic_loader SRCS dynamic_loader.cc DEPS glog gflags enforce) list(APPEND CUDA_SRCS cublas.cc cudnn.cc curand.cc nccl.cc) +configure_file(cupti_lib_path.h.in ${CMAKE_CURRENT_BINARY_DIR}/cupti_lib_path.h) if (CUPTI_FOUND) list(APPEND CUDA_SRCS cupti.cc) endif(CUPTI_FOUND) diff --git a/paddle/fluid/platform/dynload/cupti_lib_path.h.in b/paddle/fluid/platform/dynload/cupti_lib_path.h.in new file mode 100644 index 00000000000..017384bfbb7 --- /dev/null +++ b/paddle/fluid/platform/dynload/cupti_lib_path.h.in @@ -0,0 +1,17 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +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. */ + +#pragma once + +#define CUPTI_LIB_PATH "@CUPTI_LIBRARY_PATH@" diff --git a/paddle/fluid/platform/dynload/dynamic_loader.cc b/paddle/fluid/platform/dynload/dynamic_loader.cc index 8eb5966e577..e590e81bab5 100644 --- a/paddle/fluid/platform/dynload/dynamic_loader.cc +++ b/paddle/fluid/platform/dynload/dynamic_loader.cc @@ -19,6 +19,7 @@ limitations under the License. */ #include #include "gflags/gflags.h" #include "glog/logging.h" +#include "paddle/fluid/platform/dynload/cupti_lib_path.h" #include "paddle/fluid/platform/enforce.h" DEFINE_string(cudnn_dir, "", @@ -45,8 +46,7 @@ DEFINE_string(cupti_dir, "", "Specify path for loading cupti.so."); namespace paddle { namespace platform { namespace dynload { - -static const char* cupti_lib_path = CUPTI_LIB_PATH; +static constexpr char cupti_lib_path[] = CUPTI_LIB_PATH; static inline std::string join(const std::string& part1, const std::string& part2) { -- GitLab