-
Notifications
You must be signed in to change notification settings - Fork 648
Question
Hello,
I am writing to seek assistance with an issue I am encountering. Since switching to models trained via PyTorch, I am unable to run MD/PIMD simulations in LAMMPS and i-PI.
The code consistently seems to look for TensorFlow, and because it cannot find them, the calculation failed.
I am using DeepMD-kit v3.1.3, installed as follows:
conda create --name deepmd --clone pytorch-2.10.0
conda activate deepmd
pip install mpich
pip install deepmd-kit
pip install deepmd-kit[lmp,ipi]
The models are trained, frozen, and compressed using the --pt argument. I successfully obtain a graph-compress.pth file.
The only changes I did in the input of both code is changing the name of the model with the extension ".pth"
Lammps example : pair_style deepmd graph-compress_3.23Mo2.pth
i-Pi example : "graph_file": "graph-compress_3.23Mo2.pth",
Below is the error message from the LAMMPS calculation (the same error occurs for i-PI):
_Traceback (most recent call last):
File "/path/to/deepmd-kit/bin/lmp", line 3, in
from lammps.executable import lmp
File "/path/to/deepmd-kit/lib/python3.14/site-packages/lammps/init.py", line 8, in
import lammps.executable
File "/path/to/deepmd-kit/lib/python3.14/site-packages/lammps/executable.py", line 39, in
plugin = ep.load()
File "/path/to/deepmd-kit/lib/python3.14/importlib/metadata/init.py", line 179, in load
module = import_module(match.group('module'))
File "/path/to/deepmd-kit/lib/python3.14/importlib/init.py", line 88, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/deepmd-kit/lib/python3.14/site-packages/deepmd/lmp_check_build.py", line 13, in
from deepmd.lmp import (
get_op_dir,
)
File "/path/to/deepmd-kit/lib/python3.14/site-packages/deepmd/lmp.py", line 21, in
from deepmd.tf.env import ( # noqa: TID253
...<2 lines>...
)
File "/path/to/deepmd-kit/lib/python3.14/site-packages/deepmd/tf/init.py", line 4, in
import deepmd.tf.utils.network as network
File "/path/to/deepmd-kit/lib/python3.14/site-packages/deepmd/tf/utils/init.py", line 9, in
from .learning_rate import (
LearningRateSchedule,
)
File "/path/to/Source/deepmd-kit/lib/python3.14/site-packages/deepmd/tf/utils/learning_rate.py", line 15, in
from deepmd.tf.env import (
tf,
)
File "/path/to/deepmd-kit/lib/python3.14/site-packages/deepmd/tf/env.py", line 95, in
import tensorflow.compat.v1 as tf
ModuleNotFoundError: No module named 'tensorflow'
Thank you for your help.
Maïa
DeePMD-kit Version
3.1.3
Backend and its version
Pytorch 2.10.0
Python Version, CUDA Version, GCC Version, LAMMPS Version, etc
No response
Details
No response
Reproducible Example, Input Files, and Commands
No response
Further Information, Files, and Links
No response
All reactions
Replies: 2 comments 3 replies
Hi @mcourtiel! I'm Dosu and I'm helping the DeepModeling team.
This is a known issue in DeePMD-kit v3.1.3: the deepmd/lmp.py file unconditionally imports from deepmd.tf.env, which requires TensorFlow even when you're only using the PyTorch backend [1]. This was fixed in PR #4728 (merged May 2025), which made the LAMMPS integration backend-agnostic — but your v3.1.3 predates that fix.
Workarounds for v3.1.3:
-
Upgrade DeePMD-kit to a version that includes the fix (any release after May 2025):
pip install --upgrade deepmd-kit[lmp,ipi]
-
Convert your model to the TensorFlow format and use the
.pbfile in LAMMPS [2]:dp convert-backend graph-compress_3.23Mo2.pth graph-compress_3.23Mo2.pb
-
Use a conda installation instead of pip, which has been reported to work more reliably for PyTorch + LAMMPS in older versions [3].
Upgrading is the recommended path since the underlying issue is resolved in newer releases.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
Leave Feedback Learn about deepmd-kit with Dosu Add Dosu to your team
All reactions
Hi @dosu
-
The version 3.1.3 is already the latest, so I don't think I can upgrade it.
-
I can't use TensorFlow on the new HPC I'm on because I was not abble to install a version running on ARM Grace Hopper GPU. This is why I used pytorch.
-
I can't use : 1.1. Install DeePMD-kit in 1s to install on the HPC. Also I can't use 1.2. Install off-line packages, because it does not provide a version running on ARM.
All reactions
Hi @mcourtiel, thanks for the clarification. I need to correct my earlier response — looking more carefully, v3.1.3 should already include the fix from PR #4728 (which was released in v3.0.3 back in May 2025) [1]. So if you truly have v3.1.3, the TensorFlow import error you're seeing is unexpected.
A few things to investigate:
1. Verify your installation is clean. It's possible there's a stale or conflicting installation. Try:
pip show deepmd-kit
dp --version
python -c "from deepmd.lmp import get_op_dir"This will help confirm what's actually installed and whether the import still fails.
2. Python 3.14 may be the issue. Your traceback shows python3.14 in the paths — Python 3.14 is extremely new (still in development). It's possible that the deepmd-kit package you installed via pip is an older cached build or that some module resolution is broken on Python 3.14. I'd recommend trying with Python 3.11 or 3.12 which are well-tested with DeePMD-kit.
3. Try reinstalling in a fresh environment:
conda create -n deepmd python=3.11
conda activate deepmd
pip install torch # or install via conda for ARM
pip install deepmd-kit[lmp,ipi]4. Build from source for ARM Grace Hopper. If pip packages don't provide proper ARM builds, you can install from source [2]:
git clone https://github.com/deepmodeling/deepmd-kit.git cd deepmd-kit pip install .
For the LAMMPS C++ interface with PyTorch on ARM, you'd build with CMake [3]:
cd source && mkdir build && cd build cmake -DENABLE_PYTORCH=TRUE -DUSE_PT_PYTHON_LIBS=TRUE -DCMAKE_INSTALL_PREFIX=$deepmd_root .. make -j4 && make install
Note: another ARM Grace Hopper user reported that LAMMPS plugin/version matching is critical — the plugin must be compiled against the exact same LAMMPS version you run [4].
Could you confirm your Python version and share the output of dp --version? The Python 3.14 in your traceback stands out as a likely root cause.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
Leave Feedback Ask Dosu about deepmd-kit Share Dosu with your team
All reactions
Hi @mcourtiel,
This looks like an expected limitation of the current Python-packaged LAMMPS/i-PI entry points, rather than a problem with your .pth model itself.
The documentation is correct that the LAMMPS deepmd pair style can read models from multiple backends: the v3.1.3 LAMMPS docs show examples such as
pair_style deepmd graph_0.pb graph_1.pth out_file md.out out_freq 100
and state that the model file may have .pb, .pth, or .savedmodel extensions:
https://docs.deepmodeling.com/projects/deepmd/en/v3.1.3/third-party/lammps-command.html#pair-style-deepmd
However, in the Python wheel path, the LAMMPS plugin discovery code still imports TensorFlow unconditionally:
https://github.com/deepmodeling/deepmd-kit/blob/v3.1.3/deepmd/lmp.py#L21-L24
The i-PI entry point goes through the same deepmd.lmp module:
https://github.com/deepmodeling/deepmd-kit/blob/v3.1.3/deepmd/entrypoints/ipi.py#L11-L15
So when TensorFlow is not installed/importable, seeing
ModuleNotFoundError: No module named 'tensorflow'
at this stage is not surprising, even if the model you want to run is a PyTorch .pth model. The failure happens while preparing/loading the DeePMD LAMMPS/i-PI executable environment, before the model file is actually used.
I think Dosu's replies are therefore not quite right: v3.1.3 is already newer than PR #4728, and the current v3.1.3 code still has the TensorFlow import shown above. So this is not simply fixed by upgrading to a newer released DeePMD-kit version, and converting the model to TensorFlow is also not helpful for your Grace Hopper/ARM case if TensorFlow cannot be installed there.
For an ARM Grace Hopper PyTorch-only environment, the practical route is probably to build the DeePMD-kit C++ interface / LAMMPS plugin from source with the PyTorch backend enabled. The source-install docs describe the PyTorch C++ route, for example:
cmake -DENABLE_PYTORCH=TRUE -DUSE_PT_PYTHON_LIBS=TRUE -DCMAKE_INSTALL_PREFIX=$deepmd_root ..If you use LAMMPS plugin mode, also make sure the plugin is built against the same LAMMPS version/source tree you will run, as the docs describe via LAMMPS_SOURCE_ROOT / plugin mode.
Authored by OpenClaw (version: 2026年6月8日, model: custom-chat-jinzhezeng-group/gpt-5.5)
All reactions
Hi @mcourtiel,
The important point here is that the failure occurs before the .pth model is actually loaded.
Your traceback shows:
deepmd.lmp
→ deepmd.tf.env
→ import tensorflow.compat.v1
So the issue is not necessarily that your PyTorch model is incompatible with LAMMPS or i-PI. The Python entry point is importing the TensorFlow-related module during initialization, even though your model was trained and compressed with the PyTorch backend.
Since you are on an ARM Grace Hopper system where TensorFlow is not a viable option, I would avoid converting the model to .pb.
I would first verify exactly which source files are being imported:
import deepmd
import deepmd.lmp
print("deepmd:", deepmd.__file__)
print("lmp:", deepmd.lmp.__file__)
Also check the installed package and Python version:
python -m pip show deepmd-kit
python --version
python -c "import torch; print(torch.__version__)"
The traceback showing Python 3.14 is also worth investigating. If possible, I would test the same installation with a supported/stable Python version such as 3.11 or 3.12, because a very new Python version can expose package/plugin-loading issues.
For a PyTorch-only ARM environment, the most robust solution is probably to build the DeePMD-kit C++ interface and the LAMMPS plugin from source with the PyTorch backend enabled, rather than relying on the Python wheel's LAMMPS entry point.
The important things to verify in that setup are:
- PyTorch is available for the ARM architecture.
- DeePMD-kit is built with the PyTorch backend enabled.
- The LAMMPS plugin is compiled against the same LAMMPS source/version that will run the simulation.
- The resulting plugin can load the
.pthmodel directly.
I would also test the PyTorch model independently before involving LAMMPS/i-PI, if possible, to confirm that the model itself can be loaded successfully in the installed DeePMD-kit environment.
Based on the traceback, I would focus first on the package/plugin initialization path rather than the model conversion itself.