Skip to content

Instantly share code, notes, and snippets.

@link89
Last active October 30, 2024 06:33
Show Gist options
  • Select an option

  • Save link89/6eb4c74081bf7f1112e5e62e642b0580 to your computer and use it in GitHub Desktop.

Select an option

Save link89/6eb4c74081bf7f1112e5e62e642b0580 to your computer and use it in GitHub Desktop.

Summary

  • build a new deepmd-kit plugin for an existed LAMMPS
  • export new LD_LIBRARY_PATH and LAMMPS_PLUGIN_PATH properly

Build

bash build.sh

Test

#!/bin/bash -l
#SBATCH -A ai4eceeg
#SBATCH -p gpu
#SBATCH --qos normal
#SBATCH -N 1
#SBATCH --ntasks-per-node=4
#SBATCH --job-name=train
#SBATCH --gres=gpu:1

module load anaconda/2022.5
source activate /public/groups/ai4ec/libs/conda/deepmd/3.0.0b0-cuda118
module load gsl/2.8 gcc/12.1 mpi/openmpi/4.0.3-gcc

export LD_LIBRARY_PATH=/public/groups/ai4ec/libs/deepmd-plugin/pr-4274/lib/:$LD_LIBRARY_PATH
export LAMMPS_PLUGIN_PATH=/public/groups/ai4ec/libs/deepmd-plugin/pr-4274/lib/deepmd_lmp

lmp -i in.lammps  -v restart 0

Appendix

build.sh

#!/bin/bash -l

set -e
cd /path/to/deepmd-source-dir

export NVCC_APPEND_FLAGS='-allow-unsupported-compiler'
export CAFFE2_USE_CUDNN=1
export CAFFE2_USE_CUSPARSELT=1

# to fix
# nvcc warning : incompatible redefinition for option 'compiler-bindir', the last value of this option was used
# export CUDA_HOST_COMPILER=$CC
export DP_VARIANT=cuda
export DP_ENABLE_PYTORCH=1

module load cuda/11.8
module load anaconda/2022.5
source activate /public/groups/ai4ec/libs/conda/deepmd/3.0.0b0-cuda118
# source activate /public/groups/ai4ec/libs/conda/deepmd/2.2.9/gpu

module load gcc/12.1
module load gsl/2.8
module load mpi/openmpi/4.0.3-gcc
module load dev/cmake/3.26.3

export CC=`which gcc`
export CXX=`which g++`
export FC=`which gfortran`

# build c++ module

lammps_source_dir=/public/groups/ai4ec/src/lammps-2Aug2023
deepmd_root=/public/groups/ai4ec/libs/deepmd-plugin/pr-4274
mkdir -p $deepmd_root

rm -rf source/build || true
mkdir -p source/build
cd source/build

export TORCH_CUDA_ARCH_LIST="8.0 8.6 8.9 9.0"

cmake -DUSE_TF_PYTHON_LIBS=TRUE -DENABLE_TENSORFLOW=TRUE -DCMAKE_INSTALL_PREFIX=$deepmd_root -DCAFFE2_USE_CUDNN=TRUE -DCAFFE2_USE_CUSPARSELT=TRUE -DUSE_CUDA_TOOLKIT=TRUE -DLAMMPS_SOURCE_ROOT=$lammps_source_dir -DCMAKE_PREFIX_PATH=`python3 -c 'import torch;print(torch.utils.cmake_prefix_path)'` -DCUDNN_ROOT=$CONDA_PREFIX -DCUSPARSELT_ROOT=$CONDA_PREFIX ..

make -j8
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment