Skip to content

Fix Cmake 4.0 #72486

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

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ if(APPLE AND WITH_ARM)
cmake_policy(VERSION 3.19.2)
else()
cmake_minimum_required(VERSION 3.15)
cmake_policy(VERSION 3.10)
cmake_policy(VERSION 3.12)
endif()
# use to get_property location of static lib
# https://cmake.org/cmake/help/v3.0/policy/CMP0026.html?highlight=cmp0026
cmake_policy(SET CMP0026 OLD)
cmake_policy(SET CMP0079 NEW)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(PADDLE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Expand All @@ -44,7 +43,12 @@ project(paddle CXX C)

# enable language CUDA
# TODO(Shibo Tao): remove find_package(CUDA) completely.
find_package(CUDA QUIET)
find_package(CUDAToolkit)
include_directories(${CUDAToolkit_INCLUDE_DIRS})
set(CUDA_CUDART_LIBRARY "${CUDAToolkit_LIBRARY_DIR}/lib64/libcudart.so")
set(CUDA_LIBRARIES CUDA::toolkit)
set(CUDA_TOOLKIT_ROOT_DIR ${CUDAToolkit_ROOT})

find_package(MKL CONFIG QUIET)
option(WITH_ONEMKL "Compile PaddlePaddle with oneMKL" OFF)
option(WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_FOUND})
Expand Down
2 changes: 1 addition & 1 deletion ci/run_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ EOF
else
parallel_number=8
fi
if [ $parallel_number_env != "" ]; then
if [ "$parallel_number_env" != "" ]; then
parallel_number=$parallel_number_env
fi

Expand Down
6 changes: 3 additions & 3 deletions cmake/FindNumPy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ if(PYTHON_EXECUTABLE)
"try: import numpy; print(numpy.get_include())\nexcept:pass\n")

# execute the find script
exec_program(
"${PYTHON_EXECUTABLE}" ${PROJECT_BINARY_DIR}
ARGS "FindNumpyPath.py"
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" "FindNumpyPath.py"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
OUTPUT_VARIABLE NUMPY_PATH)
elseif(_numpy_out)
message(STATUS "Python executable not found.")
Expand Down
2 changes: 0 additions & 2 deletions cmake/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ if(WITH_GPU)
add_definitions(-DPADDLE_WITH_CUDA)
add_definitions(-DEIGEN_USE_GPU)

find_package(CUDA REQUIRED)

if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS 10.1)
message(FATAL_ERROR "Paddle needs CUDA >= 10.1 to compile")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/cudnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ list(
${CUDNN_ROOT}/lib
${CUDNN_ROOT}/lib/x64
${CUDNN_ROOT}/lib/${TARGET_ARCH}-linux-gnu
${CUDNN_ROOT}/local/cuda-${CUDA_VERSION}/targets/${TARGET_ARCH}-linux/lib/
${CUDNN_ROOT}/local/cuda-${CUDAToolkit_VERSION}/targets/${TARGET_ARCH}-linux/lib/
$ENV{CUDNN_ROOT}
$ENV{CUDNN_ROOT}/lib64
$ENV{CUDNN_ROOT}/lib
Expand Down
6 changes: 3 additions & 3 deletions cmake/experiments/cuda_module_loading_lazy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ if(LINUX)
message("EXP_CUDA_MODULE_LOADING_LAZY only works with GPU")
return()
endif()
if(${CUDA_VERSION} VERSION_GREATER_EQUAL "11.7")
if(${CUDAToolkit_VERSION} VERSION_GREATER_EQUAL "11.7")
message("cuda 11.7+ already support lazy module loading")
return()
endif()
if(${CUDA_VERSION} VERSION_LESS "12.0" AND ${CMAKE_CXX_COMPILER_VERSION}
VERSION_GREATER_EQUAL 12.0)
if(${CUDAToolkit_VERSION} VERSION_LESS "12.0"
AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 12.0)
message("cuda less than 12.0 doesn't support gcc12")
return()
endif()
Expand Down
3 changes: 2 additions & 1 deletion cmake/external/cutlass.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ add_definitions("-DPADDLE_WITH_CUTLASS")
add_definitions("-DSPCONV_WITH_CUTLASS=0")

if(NOT PYTHON_EXECUTABLE)
find_package(PythonInterp REQUIRED)
find_package(Python3 COMPONENTS Interpreter Development)
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
endif()

ExternalProject_Add(
Expand Down
9 changes: 7 additions & 2 deletions cmake/external/python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ include(python_module)
check_py_version(${PY_VERSION})

# Find Python with minimum PY_VERSION specified or will raise error!
find_package(PythonInterp ${PY_VERSION} REQUIRED)
find_package(PythonLibs ${PY_VERSION} REQUIRED)
execute_process(
COMMAND which python
OUTPUT_VARIABLE Python3_EXECUTABLE
OUTPUT_STRIP_TRAILING_WHITESPACE)
find_package(Python3 ${PY_VERSION} REQUIRED COMPONENTS Interpreter Development)
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
include_directories(${Python3_INCLUDE_DIRS})

if(WIN32)
execute_process(
Expand Down
14 changes: 4 additions & 10 deletions cmake/generic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,11 @@ function(merge_static_libs TARGET_NAME)
set(mri_file
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.mri
CACHE INTERNAL "phi_static.mri file")
get_property(
ABS_MERGE_LIB_PATH
TARGET ${TARGET_NAME}
PROPERTY LOCATION)
set(ABS_MERGE_LIB_PATH $<TARGET_FILE:${TARGET_NAME}>)
file(WRITE ${mri_file} "create ${ABS_MERGE_LIB_PATH}\n")

foreach(lib ${libs})
get_property(
ABS_LIB_PATH
TARGET ${lib}
PROPERTY LOCATION)
set(ABS_LIB_PATH $<TARGET_FILE:${lib}>)
file(APPEND ${mri_file} "addlib ${ABS_LIB_PATH}\n")
endforeach()
file(APPEND ${mri_file} "save\nend\n")
Expand Down Expand Up @@ -1146,8 +1140,8 @@ function(py_proto_compile TARGET_NAME)
COMMAND ${PYTHON_EXECUTABLE} ${PADDLE_SOURCE_DIR}/cmake/replace_string.py
${py_src}
COMMENT
"Replacing 'paddle.fluid' with 'paddle.base' generated by protobuf"
COMMENT "Replace ${py_src}")
"Replacing 'paddle.fluid' with 'paddle.base' generated by protobuf ${py_src}"
)
endforeach()

add_custom_target(${TARGET_NAME} ALL DEPENDS protobuf ${TARGET_NAME}_replace)
Expand Down
2 changes: 1 addition & 1 deletion cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function(version version_file)
"WITH_IPU: ${WITH_IPU}\n")
if(WITH_GPU)
file(APPEND ${version_file}
"CUDA version: ${CUDA_VERSION}\n"
"CUDA version: ${CUDAToolkit_VERSION}\n"
"CUDNN version: v${CUDNN_MAJOR_VERSION}.${CUDNN_MINOR_VERSION}\n")
endif()
if(WITH_ROCM)
Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/distributed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if(WITH_PYTHON)
add_custom_target(ps_py_proto_init)
add_custom_command(
TARGET ps_py_proto_init
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
${PADDLE_BINARY_DIR}/python/paddle/distributed/fleet/proto)
add_dependencies(ps_py_proto ps_py_proto_init)
Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ if(WITH_PYTHON)
add_custom_target(fleet_proto_init)
add_custom_command(
TARGET fleet_proto_init
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
${PADDLE_BINARY_DIR}/python/paddle/distributed/fleet/proto
COMMAND
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(static_bw_op_yaml_file ${ops_yaml_dir}/legacy/static_backward.yaml)
set(fused_bw_op_yaml_file ${ops_yaml_dir}/fused_backward.yaml)

if(NOT PYTHONINTERP_FOUND)
find_package(PythonInterp REQUIRED)
find_package(Python3 COMPONENTS Interpreter Development)
endif()

function(install_py_pyyaml)
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/api/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ set(operants_manager_header_file_tmp ${operants_manager_header_file}.tmp)
set(operants_manager_source_file_tmp ${operants_manager_source_file}.tmp)

if(NOT PYTHONINTERP_FOUND)
find_package(PythonInterp REQUIRED)
find_package(Python3 COMPONENTS Interpreter Development)
endif()

execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install pyyaml)
Expand Down
3 changes: 3 additions & 0 deletions tools/dockerfile/ci_dockerfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ function make_cpu_dockerfile(){
sed -i 's#/usr/local/gcc-8.2/bin/gcc#/usr/bin/gcc-13#g' ${dockerfile_name}
sed -i 's#/usr/local/gcc-8.2/bin/g++#/usr/bin/g++-13#g' ${dockerfile_name}
sed -i 's#ENV PATH=/usr/local/gcc-8.2/bin:$PATH##g' ${dockerfile_name}
sed -i 's#cmake-3.18.0-Linux#cmake-4.0.1-linux#g' ${dockerfile_name}
sed -i 's#v3.18#v4.0#g' ${dockerfile_name}

}


Expand Down
Loading