You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
本教程适用于 Linux(with NVIDIA GPU) 及 Mac(with Apple Silicon)
Since some users may find installing DeePMD-kit from source to be challenging and rarely attempt it, this guide aims to make the process more accessible. Installing from source offers the highest flexibility. To promote this method and reduce potential pitfalls, I have compiled a broadly applicable installation tutorial based on my own experience and the official documentation. You are encouraged to try it out.
This tutorial is applicable to Linux (with NVIDIA GPU) and Mac (with Apple Silicon).
注:
安装过程不强制要求sudo权限
若在有sudo权限的电脑上,可自行安装 CUDA Toolkit 以及 mpi(可选)
在 HPC 集群上可通过source\module方式加载 CUDA Toolkit 以及 mpi 环境
默认安装在用户 home 目录 Software 目录下,若需要修改路径,请修改教程中涉及路径的命令
本教程需有一定计算机(linux)操作常识,若遇到问题,可以评论沟通或询问 AI
Notes:
The installation process does not strictly require sudo privileges.
If you have sudo privileges, you may install CUDA Toolkit and MPI (optional) yourself.
On HPC clusters, you can load CUDA Toolkit and MPI environments using source or module commands.
By default, the installation path is set to the user's home directory under the Software folder. If you wish to change the path, please modify the relevant commands in the tutorial.
This tutorial assumes some basic knowledge of computer (Linux) operations. If you encounter any issues, feel free to comment or ask AI for help.
# pytorch
python -c "import torch; print('PyTorch devices:', [torch.cuda.get_device_name(i) for i in range(torch.cuda.device_count())] if torch.cuda.is_available() else 'CPU')"# tensorflow
python -c "import tensorflow as tf; print('TF devices:', tf.config.list_physical_devices('GPU'))"# JAX
python -c "import jax; print('JAX devices:', jax.devices())"# All in One
python -c "import torch, tensorflow as tf, jax; print('PyTorch: ', [torch.cuda.get_device_name(i) for i in range(torch.cuda.device_count())] if torch.cuda.is_available() else 'CPU'); print('TF: ', tf.config.list_physical_devices('GPU')); print('JAX: ', jax.devices())"
If one does not need to use DeePMD-kit with LAMMPS or i-PI, then the python interface installed in the previous section does everything and he/she can safely skip this section.
# 0. (Optional) for reinstallexport software="$HOME/Software"&& rm -rfv $software/deepmd-kit_cpp $software/deepmd-kit/source/build
# 1. Environment Variablesexport deepmd_source_dir=$(pwd)&& mkdir -p ../deepmd-kit_cpp &&cd ../deepmd-kit_cpp &&export deepmd_root=$(pwd)&&cd ../deepmd-kit &&cdsource&& mkdir -p build &&cd build
# export deepmd_source_dir="$software/deepmd-kit"# export deepmd_root="$software/deepmd-kit_cpp"# 2. CMake (Choice either one)# 2.1 Option 1: use pytorch & tensorflow & jax (from python env)
cmake -DCMAKE_INSTALL_PREFIX=$deepmd_root \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_NATIVE_OPTIMIZATION=ON \
-DUSE_CUDA_TOOLKIT=ON \
-DENABLE_PYTORCH=ON \
-DUSE_PT_PYTHON_LIBS=ON \
-DENABLE_TENSORFLOW=ON \
-DUSE_TF_PYTHON_LIBS=ON \
-DENABLE_JAX=ON \
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX ..
# 2.2 Option 2: use pytorch only (from python env)
cmake -DCMAKE_INSTALL_PREFIX=$deepmd_root \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_NATIVE_OPTIMIZATION=ON \
-DUSE_CUDA_TOOLKIT=ON \
-DENABLE_PYTORCH=ON \
-DUSE_PT_PYTHON_LIBS=ON \
-DENABLE_TENSORFLOW=OFF \
-DUSE_TF_PYTHON_LIBS=OFF \
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX ..
# 2.3 Option 3: use libtorch (standalone)
wget https://download.pytorch.org/libtorch/cu128/libtorch-cxx11-abi-shared-with-deps-latest.zip
unzip libtorch-cxx11-abi-shared-with-deps-latest.zip
# Note: $software/libtorch is the unzipped dir, CMAKE_INSTALL_PREFIX is set to a local dir
cmake -DCMAKE_INSTALL_PREFIX="../../install" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_NATIVE_OPTIMIZATION=ON \
-DUSE_CUDA_TOOLKIT=ON \
-DENABLE_PYTORCH=ON \
-DUSE_PT_PYTHON_LIBS=OFF \
-DCMAKE_PREFIX_PATH=$software/libtorch ..
# 3. Install
make -j && make install
# 4. (Optional) Link cmake cache
rm $software/deepmd-kit/compile_commands.json ; ln -s "$(pwd)/compile_commands.json"$software/deepmd-kit
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
鉴于大家可能觉得从源码安装
DeePMD-kit门槛较高,而极少使用。然而从源码安装的灵活性最高,为进一步推广,并减少可能的坑,笔者在此根据自己的安装流程结合官方文档给出一个适用性较广的安装教程,各位可自行尝试。本教程适用于 Linux(with NVIDIA GPU) 及 Mac(with Apple Silicon)
Since some users may find installing
DeePMD-kitfrom source to be challenging and rarely attempt it, this guide aims to make the process more accessible. Installing from source offers the highest flexibility. To promote this method and reduce potential pitfalls, I have compiled a broadly applicable installation tutorial based on my own experience and the official documentation. You are encouraged to try it out.This tutorial is applicable to Linux (with NVIDIA GPU) and Mac (with Apple Silicon).
0. Preparation (Optional)
0.1 CUDA Toolkit
You can also use CUDA 12.6, 12.9 as well.
0.2 Intel® oneAPI Toolkit
1. Install Backend’s Python interface
1.1 Use Miniforge (Conda/mamba)
1.1+ Check GPU Installation
1.2 For Mac
2. Install the C++ interface
3. Install LAMMPS’s DeePMD-kit module (built-in mode)
Before following this section, DeePMD-kit C++ interface should have be installed (see 3.3)
Note on GPU Architecture: You must specify your GPU architecture via
-DGPU_ARCH=sm_XX.Check yours using
nvidia-smi -q | grep Architectureor strictly match your card model.4. DPGEN2
Beta Was this translation helpful? Give feedback.
All reactions