Skip to content

Commit e695a91

Browse files
authored
merge devel to master (v3.0.0) (#4407)
2 parents b875ea8 + 2303ff0 commit e695a91

File tree

1,566 files changed

+217864
-33846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,566 files changed

+217864
-33846
lines changed

.devcontainer/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
2+
3+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

.devcontainer/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# DeePMD-kit devcontainer environment
2+
3+
This [devcontainer](https://vscode.js.cn/docs/devcontainers/devcontainer-cli) environment setups Python and C++ environment to develop DeePMD-kit.
4+
One can setup locally or use [GitHub Codespaces](https://docs.github.com/en/codespaces) by clicking the Code button on the DeePMD-kit repository page.
5+
The whole setup process requires about 10 minutes, so one needs to be patient.
6+
7+
## Python environment
8+
9+
The following packages are installed into the Python environment `.venv`:
10+
11+
- DeePMD-kit (in edit mode)
12+
- Backends including TensorFlow, PyTorch, JAX
13+
- LAMMPS
14+
- MPICH
15+
- CMake
16+
- pre-commit (including hooks)
17+
- Test packages including pytest
18+
- Doc packages including sphinx
19+
20+
## C++ interface
21+
22+
The C++ interface with TensorFlow and PyTorch support is installed into `dp` directory.
23+
24+
When calling and debuging LAMMPS with DeePMD-kit, use the following scripts instead of the regular `lmp`:
25+
26+
- `.devcontainer/lmp`
27+
- `.devcontainer/gdb_lmp`
28+
29+
Use the following scripts for `pytest` with LAMMPS:
30+
31+
- `.devcontainer/pytest_lmp`
32+
- `.devcontainer/gdb_pytest_lmp`
33+
34+
## Rebuild
35+
36+
Usually the Python package does not need to reinstall.
37+
But when one wants to recompile the C++ code, the following scripts can be executed.
38+
39+
- `.devcontainer/build_cxx.sh`
40+
- `.devcontainer/build_py.sh`

.devcontainer/build_cxx.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
NPROC=$(nproc --all)
5+
SCRIPT_PATH=$(dirname $(realpath -s $0))
6+
7+
export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
8+
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
9+
10+
mkdir -p ${SCRIPT_PATH}/../buildcxx/
11+
cd ${SCRIPT_PATH}/../buildcxx/
12+
cmake -D ENABLE_TENSORFLOW=ON \
13+
-D ENABLE_PYTORCH=ON \
14+
-D CMAKE_INSTALL_PREFIX=${SCRIPT_PATH}/../dp/ \
15+
-D LAMMPS_VERSION=stable_29Aug2024_update1 \
16+
-D CMAKE_BUILD_TYPE=Debug \
17+
-D BUILD_TESTING:BOOL=TRUE \
18+
-D TENSORFLOW_ROOT=${TENSORFLOW_ROOT} \
19+
${SCRIPT_PATH}/../source
20+
cmake --build . -j${NPROC}
21+
cmake --install .

.devcontainer/build_py.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
SCRIPT_PATH=$(dirname $(realpath -s $0))
5+
cd ${SCRIPT_PATH}/..
6+
7+
uv sync --dev --python 3.12 --extra cpu --extra torch --extra jax --extra lmp --extra test --extra docs
8+
pre-commit install

.devcontainer/devcontainer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "DeePMD-kit",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"features": {
7+
"ghcr.io/devcontainers/features/github-cli:1": {}
8+
},
9+
"postCreateCommand": ".devcontainer/build_py.sh && .devcontainer/download_libtorch.sh && .devcontainer/build_cxx.sh && pre-commit install-hooks",
10+
"remoteEnv": {
11+
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/.venv/bin",
12+
"DP_ENABLE_PYTORCH": "1",
13+
"DP_VARIANT": "cpu",
14+
"LMP_CXX11_ABI_0": "1",
15+
"UV_EXTRA_INDEX_URL": "https://download.pytorch.org/whl/cpu"
16+
}
17+
}

.devcontainer/download_libtorch.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
SCRIPT_PATH=$(dirname $(realpath -s $0))
5+
cd ${SCRIPT_PATH}/..
6+
7+
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.5.0%2Bcpu.zip -O ~/libtorch.zip
8+
unzip ~/libtorch.zip

.devcontainer/gdb_lmp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
SCRIPT_PATH=$(dirname $(realpath -s $0))
3+
4+
export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
5+
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
6+
7+
env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
8+
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
9+
gdb ${SCRIPT_PATH}/../.venv/lib/python3.12/site-packages/lammps/lmp "$@"

.devcontainer/gdb_pytest_lmp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
SCRIPT_PATH=$(dirname $(realpath -s $0))/../..
3+
4+
export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
5+
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
6+
7+
env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
8+
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
9+
gdb --args python -m pytest -s "$@"

.devcontainer/lmp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
SCRIPT_PATH=$(dirname $(realpath -s $0))
3+
4+
export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
5+
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
6+
7+
env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
8+
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
9+
${SCRIPT_PATH}/../.venv/bin/lmp "$@"

.devcontainer/pytest_lmp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
SCRIPT_PATH=$(dirname $(realpath -s $0))/../..
3+
4+
export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
5+
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
6+
7+
env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
8+
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
9+
python -m pytest "$@"

0 commit comments

Comments
 (0)