LAMMPS compilation failed when I want to use metatensor-lammps

why I can not compile lam file after using below Instruction
I copy the error information, I need help
How can I defuse this question ?

Problem Description

When compiling LAMMPS (with the ML-METATOMIC package enabled), the linking stage failed and the error message undefined reference to cudaGetDriverEntryPointByVersion was reported. It seems that there is a conflict between the CUDA library in the conda environment and the system’s CUDA library.

cmake -DPKG_ML-METATOMIC=ON \
      -DLAMMPS_INSTALL_RPATH=ON \
      -DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
      ../cmake

output

CMake Deprecation Warning at CMakeLists.txt:22 (cmake_policy):
The OLD behavior for policy CMP0109 will be removed from a future version
of CMake.
– Running check for auto-generated files from make-based build system
– Performing Test CMAKE_HAVE_LIBC_PTHREAD
– Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
– Found Threads: TRUE
– Caffe2: Found protobuf with new-style protobuf targets.
– Caffe2: Protobuf version 31.1.0
– Found CUDAToolkit: /usr/include (found version “12.0.140”)
– The CUDA compiler identification is NVIDIA 12.0.140
– Detecting CUDA compiler ABI info
– Detecting CUDA compiler ABI info - done
– Check for working CUDA compiler: /usr/bin/nvcc - skipped
– Detecting CUDA compile features
– Detecting CUDA compile features - done
– PyTorch: CUDA detected: 12.0.140
– PyTorch: CUDA nvcc is: /usr/bin/nvcc
– PyTorch: CUDA toolkit directory:
– PyTorch: Header version is: 12.0
– Found Python: /usr/bin/python3 (found version “3.12.3”) found components: Interpreter
CMake Warning at /home/mnmt/anaconda3/envs/lammps-metatomic/share/cmake/Caffe2/public/cuda.cmake:116 (message):
Failed to compute shorthash for libnvrtc.so
Call Stack (most recent call first):
/home/mnmt/anaconda3/envs/lammps-metatomic/share/cmake/Caffe2/Caffe2Config.cmake:86 (include)
/home/mnmt/anaconda3/envs/lammps-metatomic/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
Modules/Packages/ML-METATOMIC.cmake:12 (find_package)
CMakeLists.txt:594 (include)
– Found metatensor_torch: /home/mnmt/anaconda3/envs/lammps-metatomic/lib/libmetatensor_torch.so (Required is at least version “0.8.0”)
– Caffe2: Found protobuf with new-style protobuf targets.
– Caffe2: Protobuf version 31.1.0
CMake Warning at /home/mnmt/anaconda3/envs/lammps-metatomic/share/cmake/Torch/TorchConfig.cmake:22 (message):
static library kineto_LIBRARY-NOTFOUND not found.
Call Stack (most recent call first):
/home/mnmt/anaconda3/envs/lammps-metatomic/share/cmake/Torch/TorchConfig.cmake:125 (append_torchlib_if_found)
/home/mnmt/anaconda3/envs/lammps-metatomic/lib/cmake/metatomic_torch/metatomic_torch-config.cmake:13 (find_package)
Modules/Packages/ML-METATOMIC.cmake:54 (find_package)
CMakeLists.txt:594 (include)
– Generating style headers…
– Generating package headers…
– Generating lmpinstalledpkgs.h…

– <<< Build configuration >>>
LAMMPS Version:   2025.9.10.99
Operating System: Linux Ubuntu" 24.04
CMake Version:    3.28.3
Build type:       RelWithDebInfo
Install path:     /home/mnmt/.local
Generator:        Unix Makefiles using /usr/bin/gmake
– Enabled packages: ML-METATOMIC
– <<< Compilers and Flags: >>>
– C++ Compiler:     /usr/bin/c++
Type:          GNU
Version:       13.3.0
C++ Standard:  17
C++ Flags:     -O2 -g -DNDEBUG
Defines:       LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_OMP_COMPAT=4;LAMMPS_GZIP;LAMMPS_FFMPEG
– C compiler:       /usr/bin/cc
Type:          GNU
Version:       13.3.0
C Flags:       -O2 -g -DNDEBUG
– <<< Linker flags: >>>
– Executable name:  lmp
– Static library flags:
– <<< MPI flags >>>
– MPI_defines:      MPICH_SKIP_MPICXX;OMPI_SKIP_MPICXX;_MPICC_H
– MPI includes:     /home/mnmt/anaconda3/envs/lammps-metatomic/include
– MPI libraries:    /home/mnmt/anaconda3/envs/lammps-metatomic/lib/libmpi.so;
– Configuring done (6.6s)
CMake Warning at CMakeLists.txt:250 (add_executable):
Cannot generate a safe runtime search path for target lmp because files in
some directories may conflict with libraries in implicit directories:runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/13 may be hidden by files in:
  /home/mnmt/anaconda3/envs/lammps-metatomic/lib
runtime library [libcudart.so.12] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
  /home/mnmt/anaconda3/envs/lammps-metatomic/libSome of these libraries may not be found correctly.
– Generating done (0.1s)
– Build files have been written to: /home/mnmt/software/lammps/lammps-metatomic/build

error position

when I run “cmake --build . --parallel 4“, finally output

mnmt@HP-Workstation:~/software/lammps/lammps-metatomic/build$  [ 98%] Built target lammps[ 98%] Building CXX object CMakeFiles/lmp.dir/home/mnmt/software/lammps/lammps-metatomic/src/main.cpp.o[100%] Linking CXX executable lmp/usr/bin/ld: /home/mnmt/anaconda3/envs/lammps-metatomic/lib/libc10_cuda.so: undefined reference to `[email protected]'collect2: error: ld returned 1 exit statusgmake[2]: *** [CMakeFiles/lmp.dir/build.make:188:lmp] 错误 1gmake[1]: *** [CMakeFiles/Makefile2:205:CMakeFiles/lmp.dir/all] 错误 2gmake: *** [Makefile:136:all] 错误 2


other information
run “ls -la /home/mnmt/anaconda3/envs/lammps-metatomic/lib/libcudart*”

(lammps-metatomic) mnmt@HP-Workstation:~/software/lammps/lammps-metatomic/build$ ls -la /home/mnmt/anaconda3/envs/lammps-metatomic/lib/libcudart*
lrwxrwxrwx 1 mnmt mnmt 48  1月 26 15:52 /home/mnmt/anaconda3/envs/lammps-metatomic/lib/libcudart.so.12 -> ../targets/x86_64-linux/lib/libcudart.so.12.9.79
lrwxrwxrwx 1 mnmt mnmt 48  1月 26 15:52 /home/mnmt/anaconda3/envs/lammps-metatomic/lib/libcudart.so.12.9.79 -> ../targets/x86_64-linux/lib/libcudart.so.12.9.79

Sorry, but there is no ML-METATOMIC package in LAMMPS: 8. Optional packages — LAMMPS documentation. We don’t know anything about it and thus you have to talk to whoever developed this.

Hey,

Developer of lammps-metatomic here. You already did this, but I’m adding instructions here so the next person also know where to go when they have questions: Please go and open a discussion on the github repository directly: metatensor/lammps · Discussions · GitHub

@akohlmey let me know if we should add some kind of large banner in our docs that says “please ask all questions about this in the github repo, do no use the official lammps forum at https://matsci.org/“. This would stay up until we merge our code upstream or turn it into a proper full plugin instead of a fork!

I don’t think that would make much of a difference. See my observations in the ongoing discussion here: How can we encourage (more) people to use the forum?
Sometimes, we can try to provide some assistance, if the problems could be of a general nature as in the case here: Difficulty accessing MILADY LAMMPS repository from the given download link This is just one post.We could talk again about this, in case this becomes a recurring issue.

Technically, I think we could request that any forked project would stop using the name LAMMPS (as has been done by the LIGGGHTS project on their own for example), but that is a double edged sword, since this also distracts from the fact that the core code is LAMMPS.

Given how many machine learning projects are based on LAMMPS these, I sometimes have the feeling we need to rename LAMMPS to LAMMLMPS or something similar. :wink: