Skip to content

Navigation Menu

Sign in
Sign up

Install a GPU version of DeepMD and LAMMPS #5591

achyuttt started this conversation in General
Discussion options

Hello everyone,

I had a question about using the DeepMD potential in LAMMPS. I tried to compile the DeepMD from scratch but CPU version was installed. It couldn't utilize the GPU during training. Also, can I use both GPU an CPU for the potential made using DeepMD?

I want to install a GPU version of DeepMD for training and use both GPU + CPU while performing the MD in LAMMPS.

What would be the best workflow for this purpose?

I look forward to hearing from anyone soon

Thank you!

You must be logged in to vote

Replies: 1 comment

Comment options

Hi @achyuttt,

The simplest workflow is to use the prebuilt CUDA package. A source build defaults to CPU unless CUDA is explicitly enabled.

For NVIDIA/CUDA 12 with TensorFlow training and LAMMPS, create a fresh environment and run:

python -m venv deepmd
source deepmd/bin/activate
python -m pip install -U pip
python -m pip install "deepmd-kit[gpu,cu12,lmp]"

A compatible NVIDIA driver must already be installed. You can verify that TensorFlow sees the GPU with:

python -c "import tensorflow as tf; print(tf.config.list_physical_devices(\"GPU\"))"

When training starts, the DeePMD log should report a computing device such as gpu:0.

If you prefer to build from source, the important options are:

DP_VARIANT=cuda python -m pip install .

and, for the C++ interface used by LAMMPS, add -DUSE_CUDA_TOOLKIT=TRUE to CMake, together with the selected backend, for example:

cmake -DENABLE_TENSORFLOW=TRUE \
 -DUSE_TF_PYTHON_LIBS=TRUE \
 -DUSE_CUDA_TOOLKIT=TRUE \
 -DCMAKE_INSTALL_PREFIX=$deepmd_root ..

The missing DP_VARIANT=cuda or USE_CUDA_TOOLKIT=TRUE is likely why your source build became CPU-only.

For the usual TensorFlow .pb or PyTorch .pth frozen models, you do not need to train separate CPU and GPU potentials. The same model can be evaluated on either device when the matching backend/runtime supports it. However, a single DeepMD pair evaluation is not split across the CPU and GPU. In a GPU LAMMPS run, the DeepMD kernels execute on the GPU while LAMMPS, MPI, and host-side work still use CPU resources.

Typical launches are:

# One GPU
CUDA_VISIBLE_DEVICES=0 lmp -in in.lammps
# Two GPUs: one MPI rank per GPU
CUDA_VISIBLE_DEVICES=0,1 mpirun -np 2 lmp -in in.lammps
# Force a CPU-only run
CUDA_VISIBLE_DEVICES="" lmp -in in.lammps

Each MPI rank can use at most one GPU. For multiple GPUs, use one rank per GPU as a starting point and benchmark the rank/thread settings for your system.

Relevant documentation:

If the GPU is still not detected, please share the output of nvidia-smi, dp --version, the TensorFlow GPU check above, and the exact build/install command.

Coding agent: Codex
Codex version: codex-cli 0.144.6
Model: gpt-5.6-sol
Reasoning effort: xhigh

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /