-
Notifications
You must be signed in to change notification settings - Fork 609
feat(dev): setup devcontainer for developers #4263
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04 | ||
|
|
||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # DeePMD-kit devcontainer environment | ||
|
|
||
| This [devcontainer](https://vscode.js.cn/docs/devcontainers/devcontainer-cli) environment setups Python and C++ environment to develop DeePMD-kit. | ||
| 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. | ||
| The whole setup process requires about 10 minutes, so one needs to be patient. | ||
|
|
||
| ## Python environment | ||
|
|
||
| The following packages are installed into the Python environment `.venv`: | ||
|
|
||
| - DeePMD-kit (in edit mode) | ||
| - Backends including TensorFlow, PyTorch, JAX | ||
| - LAMMPS | ||
| - MPICH | ||
| - CMake | ||
| - pre-commit (including hooks) | ||
| - Test packages including pytest | ||
| - Doc packages including sphinx | ||
|
|
||
| ## C++ interface | ||
|
|
||
| The C++ interface with TensorFlow and PyTorch support is installed into `dp` directory. | ||
|
|
||
| When calling and debuging LAMMPS with DeePMD-kit, use the following scripts instead of the regular `lmp`: | ||
|
|
||
| - `.devcontainer/lmp` | ||
| - `.devcontainer/gdb_lmp` | ||
|
|
||
| ## Rebuild | ||
|
|
||
| Usually the Python package does not need to reinstall. | ||
| But when one wants to recompile the C++ code, the following scripts can be executed. | ||
|
|
||
| - `.devcontainer/build_cxx.sh` | ||
| - `.devcontainer/build_py.sh` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/bin/bash | ||
| set -ev | ||
|
|
||
| NPROC=$(nproc --all) | ||
| SCRIPT_PATH=$(dirname $(realpath -s $0)) | ||
|
|
||
| export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch | ||
|
njzjz marked this conversation as resolved.
|
||
| TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') | ||
|
njzjz marked this conversation as resolved.
|
||
|
|
||
| mkdir -p ${SCRIPT_PATH}/../buildcxx/ | ||
| cd ${SCRIPT_PATH}/../buildcxx/ | ||
| cmake -D ENABLE_TENSORFLOW=ON \ | ||
| -D ENABLE_PYTORCH=ON \ | ||
| -D CMAKE_INSTALL_PREFIX=${SCRIPT_PATH}/../dp/ \ | ||
| -D LAMMPS_VERSION=stable_29Aug2024_update1 \ | ||
| -D CMAKE_BUILD_TYPE=Debug \ | ||
| -D BUILD_TESTING:BOOL=TRUE \ | ||
| -D TENSORFLOW_ROOT=${TENSORFLOW_ROOT} \ | ||
| ${SCRIPT_PATH}/../source | ||
|
njzjz marked this conversation as resolved.
|
||
| cmake --build . -j${NPROC} | ||
| cmake --install . | ||
|
njzjz marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/bash | ||
| set -ev | ||
|
njzjz marked this conversation as resolved.
|
||
|
|
||
| SCRIPT_PATH=$(dirname $(realpath -s $0)) | ||
| cd ${SCRIPT_PATH}/.. | ||
|
njzjz marked this conversation as resolved.
|
||
|
|
||
| uv sync --dev --python 3.12 --extra cpu --extra torch --extra jax --extra lmp --extra test --extra docs | ||
| pre-commit install | ||
|
njzjz marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "name": "DeePMD-kit", | ||
| "build": { | ||
| "dockerfile": "Dockerfile" | ||
| }, | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/github-cli:1": {} | ||
| }, | ||
|
njzjz marked this conversation as resolved.
|
||
| "postCreateCommand": ".devcontainer/build_py.sh && .devcontainer/download_libtorch.sh && .devcontainer/build_cxx.sh && pre-commit install-hooks", | ||
|
njzjz marked this conversation as resolved.
|
||
| "remoteEnv": { | ||
| "PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/.venv/bin", | ||
| "DP_ENABLE_PYTORCH": "1", | ||
| "DP_VARIANT": "cpu", | ||
| "LMP_CXX11_ABI_0": "1", | ||
| "UV_EXTRA_INDEX_URL": "https://download.pytorch.org/whl/cpu" | ||
| } | ||
|
njzjz marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/bash | ||
| set -ev | ||
|
njzjz marked this conversation as resolved.
|
||
|
|
||
| SCRIPT_PATH=$(dirname $(realpath -s $0)) | ||
| cd ${SCRIPT_PATH}/.. | ||
|
njzjz marked this conversation as resolved.
|
||
|
|
||
| wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.5.0%2Bcpu.zip -O ~/libtorch.zip | ||
|
njzjz marked this conversation as resolved.
|
||
| unzip ~/libtorch.zip | ||
|
njzjz marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/bin/bash | ||
| SCRIPT_PATH=$(dirname $(realpath -s $0)) | ||
|
njzjz marked this conversation as resolved.
|
||
|
|
||
| export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch | ||
| TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') | ||
|
njzjz marked this conversation as resolved.
|
||
|
|
||
| env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \ | ||
| LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \ | ||
| gdb ${SCRIPT_PATH}/../.venv/lib/python3.12/site-packages/lammps/lmp "$@" | ||
|
njzjz marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/bin/bash | ||
| SCRIPT_PATH=$(dirname $(realpath -s $0)) | ||
|
|
||
| export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch | ||
| TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') | ||
|
njzjz marked this conversation as resolved.
|
||
|
|
||
| env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \ | ||
| LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \ | ||
| ${SCRIPT_PATH}/../.venv/bin/lmp "$@" | ||
|
njzjz marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,3 +45,8 @@ build_c_tests | |
| build_c/ | ||
| libdeepmd_c/ | ||
| .uv/ | ||
| libtorch/ | ||
| uv.lock | ||
| buildcxx/ | ||
| node_modules/ | ||
| *.bib.original | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.