LAMMPS with KIM package compile error

Hello,
I am trying to compile LAMMPS with KIM package, but it fails.

I installed the KIM API 2.3.0.
I ran the following command.
$ source ${HOME}/local/bin/kim-api-activate
I think the installation was successful, but there may be something wrong.

$ kim-api-collections-management list

Knowledgebase of Interatomic Models (KIM)  ---  Model Collections Listing
===============================================================================

kim-api :
        kim-api 2.3.0+GNU.GNU.GNU
kim-api-uid :
        2.3.0+GNU.GNU.GNU.2023-09-05-11-06-00

kim-api configuration file:
        /home/user/.kim-api/2.3.0+GNU.GNU.GNU.2023-09-07-01-03-16/config


Environment Variables:
-------------------------------------------------------------------------------
KIM_API_CMAKE_PREFIX_DIR:
        /home/user/local

KIM_API_CONFIGURATION_FILE:
        --empty--

KIM_API_MODEL_DRIVERS_DIR:
        --empty--

KIM_API_PORTABLE_MODELS_DIR:
        --empty--

KIM_API_SIMULATOR_MODELS_DIR:
        --empty--

===============================================================================



Current Working Directory Collection
-------------------------------------------------------------------------------
Model Drivers: '/home/user/soft/20230907_lammps_cmake/lammps/build'
        --empty--

Portable Models: '/home/user/soft/20230907_lammps_cmake/lammps/build'
        --empty--

Simulator Models: '/home/user/soft/20230907_lammps_cmake/lammps/build'
        --empty--


Environment Variable Collection
-------------------------------------------------------------------------------
Model Drivers: --empty--
        --empty--

Portable Models: --empty--
        --empty--

Simulator Models: --empty--
        --empty--


User Collection
-------------------------------------------------------------------------------
Model Drivers: '/home/user/.kim-api/2.3.0+GNU.GNU.GNU.2023-09-07-01-03-16/model-drivers-dir'
        --empty--

Portable Models: '/home/user/.kim-api/2.3.0+GNU.GNU.GNU.2023-09-07-01-03-16/portable-models-dir'
        --empty--

Simulator Models: '/home/user/.kim-api/2.3.0+GNU.GNU.GNU.2023-09-07-01-03-16/simulator-models-dir'
        --empty--


System Collection
-------------------------------------------------------------------------------
Model Drivers: '/usr/local/lib/kim-api/model-drivers'
        DUNN__MD_292677547454_000
        EAM_CubicNaturalSpline__MD_853402641673_002
        EAM_Dynamo__MD_120291908751_005
…

I then followed the guidance and compiled LAMMPS with CMake build, however, the KIM package is not available.
https://docs.lammps.org/Build_extras.html#kim

$ cmake ../cmake -D DOWNLOAD_KIM=yes -D LMP_DEBUG_CURL=on -D LMP_NO_SSL_CHECK=yes -D KIM_EXTRA_UNITTESTS=yes -D PKG_ATC=yes -D PKG_MANYBODY=yes -D BUILD_SHARED_LIBS=yes
-- Appending /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/libfabric/lib:/opt/intel/compilers_and_libraries_2020.1.217/linux/ipp/lib/intel64:/opt/intel/compilers_and_libraries_2020.1.217/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/libfabric/lib:/opt/intel/compilers_and_libraries_2020.1.217/linux/ipp/lib/intel64:/opt/intel/compilers_and_libraries_2020.1.217/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/../tbb/lib/intel64_lin/gcc4.4:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/../tbb/lib/intel64_lin/gcc4.8 to CMAKE_LIBRARY_PATH: /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/libfabric/lib:/opt/intel/compilers_and_libraries_2020.1.217/linux/ipp/lib/intel64:/opt/intel/compilers_and_libraries_2020.1.217/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/libfabric/lib:/opt/intel/compilers_and_libraries_2020.1.217/linux/ipp/lib/intel64:/opt/intel/compilers_and_libraries_2020.1.217/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/../tbb/lib/intel64_lin/gcc4.4:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/../tbb/lib/intel64_lin/gcc4.8
-- Running check for auto-generated files from make-based build system
-- Generating style headers...
-- Generating package headers...
-- Generating lmpinstalledpkgs.h...
-- The following tools and libraries have been found and configured:
 * Git
 * MPI
 * OpenMP
 * LAPACK
 * Threads
 * BLAS
 * Python
 * Python3
 * ClangFormat (required version >= 8.0)

-- <<< Build configuration >>>
   LAMMPS Version:   20230802 patch_2Aug2023-363-g595f2db72f
   Operating System: Linux Ubuntu" 22.04
   CMake Version:    3.27.4
   Build type:       RelWithDebInfo
   Install path:     /home/user/.local
   Generator:        Unix Makefiles using /usr/bin/gmake
-- Enabled packages: ATC;MANYBODY
-- <<< Compilers and Flags: >>>
-- C++ Compiler:     /usr/bin/c++
      Type:          GNU
      Version:       11.4.0
      C++ Flags:     -O2 -g -DNDEBUG
      Defines:       LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_OMP_COMPAT=4;LAMMPS_GZIP
-- C compiler:       /usr/bin/cc
      Type:          GNU
      Version:       11.4.0
      C Flags:       -O2 -g -DNDEBUG
-- <<< Linker flags: >>>
-- Executable name:  lmp
-- Shared library flags:
-- <<< MPI flags >>>
-- MPI_defines:      MPICH_SKIP_MPICXX;OMPI_SKIP_MPICXX;_MPICC_H
-- MPI includes:     /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/include
-- MPI libraries:    /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/lib/libmpicxx.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/lib/release/libmpi.so;/usr/lib/x86_64-linux-gnu/librt.a;/usr/lib/x86_64-linux-gnu/libpthread.a;/usr/lib/x86_64-linux-gnu/libdl.a;
-- Configuring done (2.3s)
-- Generating done (0.1s)
-- Build files have been written to: /home/user/soft/20230907_lammps_cmake/lammps/build
$ cmake --build .
$ ls
CMakeCache.txt  LAMMPSConfig.cmake         Makefile             etc       liblammps.pc  liblammps.so.0   lmp
CMakeFiles      LAMMPSConfigVersion.cmake  cmake_install.cmake  includes  liblammps.so  liblammps_atc.a  styles
$ lmp -h | grep kim
create_box      delete_atoms    delete_bonds    box             kim_init
kim_interactions                kim_param       kim_property    kim_query

I believe that if successful, it will be labeled KIM as follows

$ lmp -h | grep kim
Usage example: /home/user/soft/20230905_kim_update/lammps/src/lmp_intel_cpu_intelmpi -var t 300 -echo screen -in in.alloy
hybrid/scaled   kim             lcbop           lj/cut          lj/cut/coul/cut
create_box      delete_atoms    delete_bonds    box             kim_init
kim_interactions                kim_param       kim_property    kim_query
dihedral_write  displace_atoms  info            kim             minimize

I would be grateful to you for any assistance.

Hi,

It appears that your KIM installation is successful, and the issue is with your LAMMPS build.

You should not use DOWNLOAD_KIM=yes option when building LAMMPS. This is intended for debugging only, and causes issues. You do need the PKG_KIM=on option. I believe as you are building now, it is not trying to find the KIM API at all. So I think if you just take out DOWNLOAD_KIM=yes and add PKG_KIM=on, to your CMake config, it should work.

We also have a question for you – how did you arrive at the decision to use DOWNLOAD_KIM=yes? Was it just from looking at the LAMMPS documentation, or did some person or source recommend this option to you? It is a repeated source of support requests, so we try to monitor why people try to use this option.

Hopefully this fixes your issue, let us know if you need more help!

Cheers, ilia

1 Like

Thank you for your reply!

I understood that DOWNLOAD_KIM=yes was an unnecessary option.
It was just from looking at the LAMMPS documentation.

I tried to compile with additional “-D PKG_KIM=yes” and “-D PKG_PYTHON=yes”, but it fails.

$ cmake ../cmake -D PKG_KIM=yes -D LMP_DEBUG_CURL=on -D LMP_NO_SSL_CHECK=yes -D KIM_EXTRA_UNITTESTS=yes -D LMP_NO_SSL_CHECK=yes -D PKG_ATC=yes -D PKG_MANYBODY=yes -D BUILD_SHARED_LIBS=yes -D PKG_PYTHON=yes
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.34.1")
-- Appending /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/libfabric/lib:/opt/intel/compilers_and_libraries_2020.1.217/linux/ipp/lib/intel64:/opt/intel/compilers_and_libraries_2020.1.217/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/../tbb/lib/intel64_lin/gcc4.4:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/../tbb/lib/intel64_lin/gcc4.8 to CMAKE_LIBRARY_PATH: /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/libfabric/lib:/opt/intel/compilers_and_libraries_2020.1.217/linux/ipp/lib/intel64:/opt/intel/compilers_and_libraries_2020.1.217/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/tbb/lib/intel64/gcc4.8:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/../tbb/lib/intel64_lin/gcc4.4:/opt/intel/compilers_and_libraries_2020.1.217/linux/daal/../tbb/lib/intel64_lin/gcc4.8
-- Running check for auto-generated files from make-based build system
-- Found MPI_CXX: /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/lib/libmpicxx.so (found version "3.1")
-- Found MPI: TRUE (found version "3.1")
-- Looking for C++ include omp.h
-- Looking for C++ include omp.h - found
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5") found components: CXX
-- The C compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sgemm_
-- Looking for sgemm_ - not found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Looking for sgemm_
-- Looking for sgemm_ - found
-- Found BLAS: /opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_intel_lp64.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_intel_thread.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_core.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/compiler/lib/intel64_lin/libiomp5.so;-lm;-ldl
-- Looking for cheev_
-- Looking for cheev_ - found
-- Found LAPACK: /opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_intel_lp64.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_intel_thread.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_core.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/compiler/lib/intel64_lin/libiomp5.so;-lm;-ldl;-lm;-ldl
-- Found GZIP: /usr/bin/gzip
-- Found FFMPEG: /usr/bin/ffmpeg
-- Found Python: /home/user/anaconda3/bin/python3.7 (found version "3.7.6") found components: Interpreter
-- Found Python: /home/user/anaconda3/bin/python3.7 (found version "3.7.6") found components: Interpreter Development Development.Module Development.Embed
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.81.0")
-- Found KIM-API: /home/user/local/lib/libkim-api.so.2.3.0
-- Looking for C++ include cmath
-- Looking for C++ include cmath - found
-- Generating style headers...
-- Generating package headers...
-- Generating lmpinstalledpkgs.h...
-- Found Python: /home/user/anaconda3/bin/python3.7 (found version "3.7.6") found components: Interpreter
-- Found Python3: /home/user/anaconda3/bin/python3.7 (found version "3.7.6") found components: Interpreter
-- Found ClangFormat: /usr/bin/clang-format (found suitable version "14.0.0", minimum required is "8.0")
-- The following tools and libraries have been found and configured:
 * Git
 * MPI
 * OpenMP
 * LAPACK
 * Threads
 * BLAS
 * CURL
 * KIM-API (required version >= 2.2.0)
 * Python
 * Python3
 * ClangFormat (required version >= 8.0)

-- <<< Build configuration >>>
   LAMMPS Version:   20230802 patch_2Aug2023-363-g595f2db72f
   Operating System: Linux Ubuntu" 22.04
   CMake Version:    3.27.4
   Build type:       RelWithDebInfo
   Install path:     /home/user/.local
   Generator:        Unix Makefiles using /usr/bin/gmake
-- Enabled packages: ATC;KIM;MANYBODY;PYTHON
-- <<< Compilers and Flags: >>>
-- C++ Compiler:     /usr/bin/c++
      Type:          GNU
      Version:       11.4.0
      C++ Flags:     -O2 -g -DNDEBUG
      Defines:       LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_OMP_COMPAT=4;LAMMPS_GZIP;LAMMPS_FFMPEG;LMP_PYTHON;LMP_KIM_CURL;LMP_DEBUG_CURL;LMP_NO_SSL_CHECK
-- C compiler:       /usr/bin/cc
      Type:          GNU
      Version:       11.4.0
      C Flags:       -O2 -g -DNDEBUG
-- <<< Linker flags: >>>
-- Executable name:  lmp
-- Shared library flags:
-- <<< MPI flags >>>
-- MPI_defines:      MPICH_SKIP_MPICXX;OMPI_SKIP_MPICXX;_MPICC_H
-- MPI includes:     /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/include
-- MPI libraries:    /opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/lib/libmpicxx.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mpi/intel64/lib/release/libmpi.so;/usr/lib/x86_64-linux-gnu/librt.a;/usr/lib/x86_64-linux-gnu/libpthread.a;/usr/lib/x86_64-linux-gnu/libdl.a;
-- Configuring done (7.6s)
CMake Warning at CMakeLists.txt:200 (add_library):
  Cannot generate a safe runtime search path for target lammps because files
  in some directories may conflict with libraries in implicit directories:

    runtime library [libcurl.so.4] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/user/anaconda3/lib
    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/11 may be hidden by files in:
      /home/user/anaconda3/lib
    runtime library [libmkl_intel_lp64.so] in /opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin may be hidden by files in:
      /home/user/anaconda3/lib
    runtime library [libmkl_intel_thread.so] in /opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin may be hidden by files in:
      /home/user/anaconda3/lib
    runtime library [libmkl_core.so] in /opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin may be hidden by files in:
      /home/user/anaconda3/lib
    runtime library [libiomp5.so] in /opt/intel/compilers_and_libraries_2020.1.217/linux/compiler/lib/intel64_lin may be hidden by files in:
      /home/user/anaconda3/lib

  Some of these libraries may not be found correctly.


CMake Warning at CMakeLists.txt:207 (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/11 may be hidden by files in:
      /home/user/anaconda3/lib

  Some of these libraries may not be found correctly.


-- Generating done (0.1s)
-- Build files have been written to: /home/user/soft/20230908_2_lammps_cmake/lammps/build
$ cmake --build .
…
[ 98%] Building CXX object CMakeFiles/lammps.dir/home/user/soft/20230908_2_lammps_cmake/lammps/src/PYTHON/python_impl.cpp.o
[ 98%] Linking CXX shared library liblammps.so
[ 98%] Built target lammps
[100%] Building CXX object CMakeFiles/lmp.dir/home/user/soft/20230908_2_lammps_cmake/lammps/src/main.cpp.o
[100%] Linking CXX executable lmp
/usr/bin/ld: liblammps.so.0: undefined reference to `curl_global_cleanup@CURL_OPENSSL_4'
/usr/bin/ld: liblammps.so.0: undefined reference to `curl_global_init@CURL_OPENSSL_4'
/usr/bin/ld: liblammps.so.0: undefined reference to `curl_easy_perform@CURL_OPENSSL_4'
/usr/bin/ld: liblammps.so.0: undefined reference to `curl_easy_init@CURL_OPENSSL_4'
/usr/bin/ld: liblammps.so.0: undefined reference to `curl_easy_strerror@CURL_OPENSSL_4'
/usr/bin/ld: liblammps.so.0: undefined reference to `curl_easy_setopt@CURL_OPENSSL_4'
/usr/bin/ld: liblammps.so.0: undefined reference to `curl_easy_cleanup@CURL_OPENSSL_4'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/lmp.dir/build.make:104: lmp] エラー 1
gmake[1]: *** [CMakeFiles/Makefile2:201: CMakeFiles/lmp.dir/all] エラー 2
gmake: *** [Makefile:136: all] エラー 2

The lib-curl was already installed.

$ sudo apt install libcurl4-openssl-dev 
$ curl-config --version
libcurl 7.68.0

I would be happy if you could help me.

Hi,

It looks like the KIM portion of the installation is working correctly for you now! The issues you are seeing are not related to KIM, and appear to be related to double instances of libraries being installed both through Conda and natively on your system (see the warnings at the end of the cmake configuration command – my guess is that curl just happens to be the first library that the compiler tries to link, so it’s not a curl-specific problem, it would have the same issue with OMP, MKL, etc.) You may have to take this to the general LAMMPS forum, but here are some ideas off the top of my head:

  1. (Probably won’t fix anything, but will make things simpler) Do you have a specific reason to use the LMP_DEBUG_CURL=on, LMP_NO_SSL_CHECK=yes and KIM_EXTRA_UNITTESTS=yes options? If not, I would omit these options
  2. Every time you try something new, it may be a good idea to do a “make clean” command
  3. If you have the freedom to do so, the easiest way might be just to remove Conda altogether
  4. If you can’t do 3, try building both inside and outside a Conda environment to see if that helps it find the libraries
1 Like

I have solved the problem.

I removed Conda and successfully compiled LAMMPS with the KIM package.

Thank you for your kind cooperation!

1 Like