From 29397da9b5ba3bf3a4c82e5fe79189f0aafb5732 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 03:26:46 +0000 Subject: [PATCH 1/4] Initial plan From 97f54133915948ec88653b9bcadd798f958dbcad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 03:35:23 +0000 Subject: [PATCH 2/4] feat: bump CMake minimum version to 3.25 Update CMake minimum required version from 3.16 to 3.25 to support RUN_OUTPUT_STDOUT_VARIABLE used in Findtensorflow.cmake. Changes: - Updated source/CMakeLists.txt main requirement - Updated backend/read_env.py for all variants (cpu, cuda, rocm) - Updated documentation in doc/install/install-from-source.md - Updated GPU-specific CMakeLists.txt files - Updated test CMakeLists.txt files - Updated example CMakeLists.txt file Fixes issue where RUN_OUTPUT_STDOUT_VARIABLE (new in CMake 3.25) was being used while minimum version was set to 3.16. Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- backend/read_env.py | 6 +++--- doc/install/install-from-source.md | 2 +- examples/infer_water/CMakeLists.txt | 2 +- source/CMakeLists.txt | 8 ++++---- source/api_c/tests/CMakeLists.txt | 2 +- source/api_cc/tests/CMakeLists.txt | 2 +- source/lib/src/gpu/CMakeLists.txt | 7 ++++--- source/lib/tests/CMakeLists.txt | 2 +- source/lmp/plugin/CMakeLists.txt | 2 +- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/backend/read_env.py b/backend/read_env.py index 482f9766a0..abf277a6e9 100644 --- a/backend/read_env.py +++ b/backend/read_env.py @@ -46,15 +46,15 @@ def get_argument_from_env() -> tuple[str, list, list, dict, str, str]: # get variant option from the environment variables, available: cpu, cuda, rocm dp_variant = os.environ.get("DP_VARIANT", "cpu").lower() if dp_variant == "cpu" or dp_variant == "": - cmake_minimum_required_version = "3.16" + cmake_minimum_required_version = "3.25" elif dp_variant == "cuda": - cmake_minimum_required_version = "3.23" + cmake_minimum_required_version = "3.25" cmake_args.append("-DUSE_CUDA_TOOLKIT:BOOL=TRUE") cuda_root = os.environ.get("CUDAToolkit_ROOT") if cuda_root: cmake_args.append(f"-DCUDAToolkit_ROOT:STRING={cuda_root}") elif dp_variant == "rocm": - cmake_minimum_required_version = "3.21" + cmake_minimum_required_version = "3.25" cmake_args.append("-DUSE_ROCM_TOOLKIT:BOOL=TRUE") rocm_root = os.environ.get("ROCM_ROOT") if not rocm_root: diff --git a/doc/install/install-from-source.md b/doc/install/install-from-source.md index a21b8913db..622c7ccc69 100644 --- a/doc/install/install-from-source.md +++ b/doc/install/install-from-source.md @@ -377,7 +377,7 @@ mkdir build cd build ``` -The installation requires CMake 3.16 or later for the CPU version, CMake 3.23 or later for the CUDA support, and CMake 3.21 or later for the ROCM support. One can install CMake via `pip` if it is not installed or the installed version does not satisfy the requirement: +The installation requires CMake 3.25 or later for all platforms (CPU, CUDA, and ROCM). One can install CMake via `pip` if it is not installed or the installed version does not satisfy the requirement: ```sh pip install -U cmake diff --git a/examples/infer_water/CMakeLists.txt b/examples/infer_water/CMakeLists.txt index 27b7541c2d..7de93b86a1 100644 --- a/examples/infer_water/CMakeLists.txt +++ b/examples/infer_water/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.25) project(infer_water) # find DeePMD-kit diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 2c13a5a367..f57ca5944b 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,5 +1,5 @@ -# new in 3.16: GET_RUNTIME_DEPENDENCIES, target_precompile_headers -cmake_minimum_required(VERSION 3.16) +# new in 3.25: RUN_OUTPUT_STDOUT_VARIABLE +cmake_minimum_required(VERSION 3.25) project(DeePMD) option(ENABLE_TENSORFLOW "Enable TensorFlow interface" OFF) @@ -244,7 +244,7 @@ set(DP_VARIANT "cpu") # define USE_CUDA_TOOLKIT if(USE_CUDA_TOOLKIT) - cmake_minimum_required(VERSION 3.23) + cmake_minimum_required(VERSION 3.25) find_package(CUDAToolkit REQUIRED) if(NOT DEFINED CMAKE_CUDA_COMPILER) set(CMAKE_CUDA_COMPILER ${CUDAToolkit_NVCC_EXECUTABLE}) @@ -261,7 +261,7 @@ endif(USE_CUDA_TOOLKIT) # define USE_ROCM_TOOLKIT if(USE_ROCM_TOOLKIT) - cmake_minimum_required(VERSION 3.21) + cmake_minimum_required(VERSION 3.25) include(CMakeDetermineHIPCompiler) list(APPEND CMAKE_PREFIX_PATH ${CMAKE_HIP_COMPILER_ROCM_ROOT}) find_package(hip REQUIRED) diff --git a/source/api_c/tests/CMakeLists.txt b/source/api_c/tests/CMakeLists.txt index c42055ba6f..c4c85f1ad6 100644 --- a/source/api_c/tests/CMakeLists.txt +++ b/source/api_c/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.25) project(deepmd_api_c_test) file(GLOB TEST_SRC test_*.cc) diff --git a/source/api_cc/tests/CMakeLists.txt b/source/api_cc/tests/CMakeLists.txt index 5599b63243..dad26fef4d 100644 --- a/source/api_cc/tests/CMakeLists.txt +++ b/source/api_cc/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.25) project(deepmd_api_test) file(GLOB TEST_SRC test_*.cc) diff --git a/source/lib/src/gpu/CMakeLists.txt b/source/lib/src/gpu/CMakeLists.txt index 0d176dc320..fa60e6607d 100644 --- a/source/lib/src/gpu/CMakeLists.txt +++ b/source/lib/src/gpu/CMakeLists.txt @@ -1,6 +1,7 @@ if(USE_CUDA_TOOLKIT) - # required cmake version 3.23: CMAKE_CUDA_ARCHITECTURES all - cmake_minimum_required(VERSION 3.23) + # required cmake version 3.25: CMAKE_CUDA_ARCHITECTURES all, + # RUN_OUTPUT_STDOUT_VARIABLE + cmake_minimum_required(VERSION 3.25) # project name project(deepmd_op_cuda) set(GPU_LIB_NAME deepmd_op_cuda) @@ -54,7 +55,7 @@ if(USE_CUDA_TOOLKIT) elseif(USE_ROCM_TOOLKIT) # required cmake version - cmake_minimum_required(VERSION 3.21) + cmake_minimum_required(VERSION 3.25) # project name project(deepmd_op_rocm) enable_language(HIP) diff --git a/source/lib/tests/CMakeLists.txt b/source/lib/tests/CMakeLists.txt index f2fd8969d9..b80fa341f1 100644 --- a/source/lib/tests/CMakeLists.txt +++ b/source/lib/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.25) project(libdeepmd_test) file(GLOB TEST_SRC test_*.cc) diff --git a/source/lmp/plugin/CMakeLists.txt b/source/lmp/plugin/CMakeLists.txt index a4e7d9e430..e531bb88fd 100644 --- a/source/lmp/plugin/CMakeLists.txt +++ b/source/lmp/plugin/CMakeLists.txt @@ -2,7 +2,7 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION) message(STATUS "enable LAMMPS plugin mode") add_library(lammps_interface INTERFACE) if(DEFINED LAMMPS_VERSION) - cmake_minimum_required(VERSION 3.14) + cmake_minimum_required(VERSION 3.25) include(FetchContent) FetchContent_Declare( lammps_download From abd9061aa666a7414b4dc36bbdd0d3e7d0d200bf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 16:23:06 +0000 Subject: [PATCH 3/4] fix: update minimum CMake version to 3.25.2 CMake 3.25.0 and 3.25.1 contain a bug (https://gitlab.kitware.com/cmake/cmake/-/issues/24275), so the minimum version is updated to 3.25.2. Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- backend/read_env.py | 6 +++--- doc/install/install-from-source.md | 2 +- examples/infer_water/CMakeLists.txt | 2 +- source/CMakeLists.txt | 6 +++--- source/api_c/tests/CMakeLists.txt | 2 +- source/api_cc/tests/CMakeLists.txt | 2 +- source/lib/src/gpu/CMakeLists.txt | 4 ++-- source/lib/tests/CMakeLists.txt | 2 +- source/lmp/plugin/CMakeLists.txt | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/backend/read_env.py b/backend/read_env.py index abf277a6e9..8a173513f9 100644 --- a/backend/read_env.py +++ b/backend/read_env.py @@ -46,15 +46,15 @@ def get_argument_from_env() -> tuple[str, list, list, dict, str, str]: # get variant option from the environment variables, available: cpu, cuda, rocm dp_variant = os.environ.get("DP_VARIANT", "cpu").lower() if dp_variant == "cpu" or dp_variant == "": - cmake_minimum_required_version = "3.25" + cmake_minimum_required_version = "3.25.2" elif dp_variant == "cuda": - cmake_minimum_required_version = "3.25" + cmake_minimum_required_version = "3.25.2" cmake_args.append("-DUSE_CUDA_TOOLKIT:BOOL=TRUE") cuda_root = os.environ.get("CUDAToolkit_ROOT") if cuda_root: cmake_args.append(f"-DCUDAToolkit_ROOT:STRING={cuda_root}") elif dp_variant == "rocm": - cmake_minimum_required_version = "3.25" + cmake_minimum_required_version = "3.25.2" cmake_args.append("-DUSE_ROCM_TOOLKIT:BOOL=TRUE") rocm_root = os.environ.get("ROCM_ROOT") if not rocm_root: diff --git a/doc/install/install-from-source.md b/doc/install/install-from-source.md index 622c7ccc69..2acad95b69 100644 --- a/doc/install/install-from-source.md +++ b/doc/install/install-from-source.md @@ -377,7 +377,7 @@ mkdir build cd build ``` -The installation requires CMake 3.25 or later for all platforms (CPU, CUDA, and ROCM). One can install CMake via `pip` if it is not installed or the installed version does not satisfy the requirement: +The installation requires CMake 3.25.2 or later for all platforms (CPU, CUDA, and ROCM). One can install CMake via `pip` if it is not installed or the installed version does not satisfy the requirement: ```sh pip install -U cmake diff --git a/examples/infer_water/CMakeLists.txt b/examples/infer_water/CMakeLists.txt index 7de93b86a1..c82816c912 100644 --- a/examples/infer_water/CMakeLists.txt +++ b/examples/infer_water/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.25) +cmake_minimum_required(VERSION 3.25.2) project(infer_water) # find DeePMD-kit diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index f57ca5944b..b69fdea72c 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,5 +1,5 @@ # new in 3.25: RUN_OUTPUT_STDOUT_VARIABLE -cmake_minimum_required(VERSION 3.25) +cmake_minimum_required(VERSION 3.25.2) project(DeePMD) option(ENABLE_TENSORFLOW "Enable TensorFlow interface" OFF) @@ -244,7 +244,7 @@ set(DP_VARIANT "cpu") # define USE_CUDA_TOOLKIT if(USE_CUDA_TOOLKIT) - cmake_minimum_required(VERSION 3.25) + cmake_minimum_required(VERSION 3.25.2) find_package(CUDAToolkit REQUIRED) if(NOT DEFINED CMAKE_CUDA_COMPILER) set(CMAKE_CUDA_COMPILER ${CUDAToolkit_NVCC_EXECUTABLE}) @@ -261,7 +261,7 @@ endif(USE_CUDA_TOOLKIT) # define USE_ROCM_TOOLKIT if(USE_ROCM_TOOLKIT) - cmake_minimum_required(VERSION 3.25) + cmake_minimum_required(VERSION 3.25.2) include(CMakeDetermineHIPCompiler) list(APPEND CMAKE_PREFIX_PATH ${CMAKE_HIP_COMPILER_ROCM_ROOT}) find_package(hip REQUIRED) diff --git a/source/api_c/tests/CMakeLists.txt b/source/api_c/tests/CMakeLists.txt index c4c85f1ad6..16698ddf09 100644 --- a/source/api_c/tests/CMakeLists.txt +++ b/source/api_c/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.25) +cmake_minimum_required(VERSION 3.25.2) project(deepmd_api_c_test) file(GLOB TEST_SRC test_*.cc) diff --git a/source/api_cc/tests/CMakeLists.txt b/source/api_cc/tests/CMakeLists.txt index dad26fef4d..cafeb3fd02 100644 --- a/source/api_cc/tests/CMakeLists.txt +++ b/source/api_cc/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.25) +cmake_minimum_required(VERSION 3.25.2) project(deepmd_api_test) file(GLOB TEST_SRC test_*.cc) diff --git a/source/lib/src/gpu/CMakeLists.txt b/source/lib/src/gpu/CMakeLists.txt index fa60e6607d..8aaf0c2904 100644 --- a/source/lib/src/gpu/CMakeLists.txt +++ b/source/lib/src/gpu/CMakeLists.txt @@ -1,7 +1,7 @@ if(USE_CUDA_TOOLKIT) # required cmake version 3.25: CMAKE_CUDA_ARCHITECTURES all, # RUN_OUTPUT_STDOUT_VARIABLE - cmake_minimum_required(VERSION 3.25) + cmake_minimum_required(VERSION 3.25.2) # project name project(deepmd_op_cuda) set(GPU_LIB_NAME deepmd_op_cuda) @@ -55,7 +55,7 @@ if(USE_CUDA_TOOLKIT) elseif(USE_ROCM_TOOLKIT) # required cmake version - cmake_minimum_required(VERSION 3.25) + cmake_minimum_required(VERSION 3.25.2) # project name project(deepmd_op_rocm) enable_language(HIP) diff --git a/source/lib/tests/CMakeLists.txt b/source/lib/tests/CMakeLists.txt index b80fa341f1..b8fbdcc00e 100644 --- a/source/lib/tests/CMakeLists.txt +++ b/source/lib/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.25) +cmake_minimum_required(VERSION 3.25.2) project(libdeepmd_test) file(GLOB TEST_SRC test_*.cc) diff --git a/source/lmp/plugin/CMakeLists.txt b/source/lmp/plugin/CMakeLists.txt index e531bb88fd..8f32af3e3e 100644 --- a/source/lmp/plugin/CMakeLists.txt +++ b/source/lmp/plugin/CMakeLists.txt @@ -2,7 +2,7 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION) message(STATUS "enable LAMMPS plugin mode") add_library(lammps_interface INTERFACE) if(DEFINED LAMMPS_VERSION) - cmake_minimum_required(VERSION 3.25) + cmake_minimum_required(VERSION 3.25.2) include(FetchContent) FetchContent_Declare( lammps_download From 90ddec10c098c9de41345af54fd1d2713e5ba590 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 2 Oct 2025 01:26:35 +0800 Subject: [PATCH 4/4] use `UV_TORCH_BACKEND` Signed-off-by: Jinzhe Zeng --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cb11d0258d..51e492c3bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -283,9 +283,8 @@ DP_ENABLE_IPI = "1" DP_ENABLE_PYTORCH = "1" DP_ENABLE_PADDLE = "1" # use CPU version of torch for building, which should also work for GPU -# note: uv has different behavior from pip on extra index url -# https://github.com/astral-sh/uv/blob/main/PIP_COMPATIBILITY.md#packages-that-exist-on-multiple-indexes -UV_EXTRA_INDEX_URL = "https://download.pytorch.org/whl/cpu" +# https://docs.astral.sh/uv/guides/integration/pytorch/#automatic-backend-selection +UV_TORCH_BACKEND = "cpu" [tool.cibuildwheel.windows] test-extras = ["cpu", "torch", "paddle"]