diff --git a/.github/workflows/build_cc.yml b/.github/workflows/build_cc.yml index 3eb162cc0b..59873c5101 100644 --- a/.github/workflows/build_cc.yml +++ b/.github/workflows/build_cc.yml @@ -33,10 +33,7 @@ jobs: - uses: lukka/get-cmake@latest - run: python -m pip install uv - run: source/install/uv_with_retry.sh pip install --system tensorflow - - name: Download libtorch - run: | - wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.1.2%2Bcpu.zip -O libtorch.zip - unzip libtorch.zip + - run: source/install/uv_with_retry.sh pip install --system 'torch==2.7' --index-url https://download.pytorch.org/whl/cpu - run: | wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb \ && sudo dpkg -i cuda-keyring_1.0-1_all.deb \ @@ -59,7 +56,6 @@ jobs: && sudo apt-get install -y rocm-dev hipcub-dev if: matrix.variant == 'rocm' - run: | - export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/libtorch source/install/build_cc.sh env: DP_VARIANT: ${{ matrix.dp_variant }} @@ -67,7 +63,6 @@ jobs: CMAKE_GENERATOR: Ninja if: matrix.variant != 'clang' - run: | - export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/libtorch source/install/build_cc.sh env: DP_VARIANT: cpu diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 583e7785d9..f8005ab831 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -41,8 +41,7 @@ jobs: && sudo apt-get update \ && sudo apt-get -y install cuda-cudart-dev-12-2 cuda-nvcc-12-2 python -m pip install tensorflow - wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.1.2%2Bcpu.zip -O libtorch.zip - unzip libtorch.zip + python -m pip install 'torch==2.7' --index-url https://download.pytorch.org/whl/cpu env: DEBIAN_FRONTEND: noninteractive # Initializes the CodeQL tools for scanning. @@ -53,7 +52,6 @@ jobs: queries: security-extended,security-and-quality - name: "Run, Build Application using script" run: | - export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/libtorch source/install/build_cc.sh env: DP_VARIANT: cuda diff --git a/.github/workflows/test_cc.yml b/.github/workflows/test_cc.yml index fb8cda80a3..3407a58d1e 100644 --- a/.github/workflows/test_cc.yml +++ b/.github/workflows/test_cc.yml @@ -32,18 +32,14 @@ jobs: source/install/uv_with_retry.sh pip install --system tensorflow-cpu~=2.18.0 jax==0.5.0 export TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') source/install/uv_with_retry.sh pip install --system -e .[cpu,test,lmp,jax] mpi4py + source/install/uv_with_retry.sh pip install --system 'torch==2.7' --index-url https://download.pytorch.org/whl/cpu - name: Convert models run: source/tests/infer/convert-models.sh - - name: Download libtorch - run: | - wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.7.0%2Bcpu.zip -O libtorch.zip - unzip libtorch.zip # https://github.com/actions/runner-images/issues/9491 - name: Fix kernel mmap rnd bits run: sudo sysctl vm.mmap_rnd_bits=28 if: ${{ matrix.check_memleak }} - run: | - export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/libtorch source/install/test_cc_local.sh env: OMP_NUM_THREADS: 1 @@ -64,7 +60,7 @@ jobs: TF_INTRA_OP_PARALLELISM_THREADS: 1 TF_INTER_OP_PARALLELISM_THREADS: 1 LAMMPS_PLUGIN_PATH: ${{ github.workspace }}/dp_test/lib/deepmd_lmp - LD_LIBRARY_PATH: ${{ github.workspace }}/dp_test/lib:${{ github.workspace }}/libtorch/lib + LD_LIBRARY_PATH: ${{ github.workspace }}/dp_test/lib if: ${{ !matrix.check_memleak }} # test ipi - run: | @@ -77,7 +73,7 @@ jobs: OMP_NUM_THREADS: 1 TF_INTRA_OP_PARALLELISM_THREADS: 1 TF_INTER_OP_PARALLELISM_THREADS: 1 - LD_LIBRARY_PATH: ${{ github.workspace }}/dp_test/lib:${{ github.workspace }}/libtorch/lib + LD_LIBRARY_PATH: ${{ github.workspace }}/dp_test/lib if: ${{ !matrix.check_memleak }} - uses: codecov/codecov-action@v5 env: diff --git a/.github/workflows/test_cuda.yml b/.github/workflows/test_cuda.yml index 85149ebb60..5f6b0e73ab 100644 --- a/.github/workflows/test_cuda.yml +++ b/.github/workflows/test_cuda.yml @@ -67,12 +67,7 @@ jobs: XLA_PYTHON_CLIENT_ALLOCATOR: platform - name: Convert models run: source/tests/infer/convert-models.sh - - name: Download libtorch - run: | - wget https://download.pytorch.org/libtorch/cu126/libtorch-cxx11-abi-shared-with-deps-2.7.0%2Bcu126.zip -O libtorch.zip - unzip libtorch.zip - run: | - export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/libtorch export LD_LIBRARY_PATH=$CUDA_PATH/lib64:/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH source/install/test_cc_local.sh env: @@ -84,7 +79,7 @@ jobs: DP_VARIANT: cuda DP_USE_MPICH2: 1 - run: | - export LD_LIBRARY_PATH=$CUDA_PATH/lib64:/usr/lib/x86_64-linux-gnu/:$GITHUB_WORKSPACE/dp_test/lib:$GITHUB_WORKSPACE/libtorch/lib:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH=$CUDA_PATH/lib64:/usr/lib/x86_64-linux-gnu/:$GITHUB_WORKSPACE/dp_test/lib:$LD_LIBRARY_PATH export PATH=$GITHUB_WORKSPACE/dp_test/bin:$PATH cp $GITHUB_WORKSPACE/source/build_tests/paddle_inference_install_dir/paddle/lib/* $GITHUB_WORKSPACE/dp_test/lib/ cp $GITHUB_WORKSPACE/source/build_tests/paddle_inference_install_dir/third_party/install/onednn/lib/* $GITHUB_WORKSPACE/dp_test/lib/ diff --git a/doc/install/install-from-source.md b/doc/install/install-from-source.md index 3a60bc1b93..1dc72c51fa 100644 --- a/doc/install/install-from-source.md +++ b/doc/install/install-from-source.md @@ -398,8 +398,7 @@ I assume you have installed the PyTorch (either Python or C++ interface) to `$to cmake -DENABLE_PYTORCH=TRUE -DCMAKE_PREFIX_PATH=$torch_root -DCMAKE_INSTALL_PREFIX=$deepmd_root .. ``` -You can specify `-DUSE_PT_PYTHON_LIBS=TRUE` to use libtorch from the Python installation, -but you need to be careful that [PyTorch PyPI packages are still built using `_GLIBCXX_USE_CXX11_ABI=0`](https://github.com/pytorch/pytorch/issues/51039), which may be not compatible with other libraries. +You can specify `-DUSE_PT_PYTHON_LIBS=TRUE` to use libtorch from the Python installation. ```bash cmake -DENABLE_PYTORCH=TRUE -DUSE_PT_PYTHON_LIBS=TRUE -DCMAKE_INSTALL_PREFIX=$deepmd_root .. diff --git a/source/install/build_cc.sh b/source/install/build_cc.sh index 17b5ed0de4..dc66343cb2 100755 --- a/source/install/build_cc.sh +++ b/source/install/build_cc.sh @@ -24,6 +24,7 @@ cmake -D ENABLE_TENSORFLOW=ON \ -D ENABLE_PYTORCH=ON \ -D CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \ -D USE_TF_PYTHON_LIBS=TRUE \ + -D USE_PT_PYTHON_LIBS=TRUE \ ${CUDA_ARGS} \ -D LAMMPS_VERSION=stable_29Aug2024_update1 \ .. diff --git a/source/install/test_cc_local.sh b/source/install/test_cc_local.sh index af142aaa2e..8152b6f1a4 100755 --- a/source/install/test_cc_local.sh +++ b/source/install/test_cc_local.sh @@ -25,6 +25,7 @@ cmake \ -D ENABLE_PADDLE=TRUE \ -D INSTALL_TENSORFLOW=FALSE \ -D USE_TF_PYTHON_LIBS=TRUE \ + -D USE_PT_PYTHON_LIBS=TRUE \ -D CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \ -D BUILD_TESTING:BOOL=TRUE \ -D LAMMPS_VERSION=stable_29Aug2024_update1 \