Multiple KIM installations or cannot find libkim-api.so

Dear KIM users,

A common issue people have with using OpenKIM potentials is being unable to find libkim-api.so, or having multiple installations of OpenKIM and the simulation program not using the correct one.

If your program cannot find libkim-api.so, it is an obvious error message, but more confusing is when you have multiple installations of the KIM API, and the program is happily using the incorrect one.

A symptom of this is if your simulations run successfully with the default potentials packaged with the API (such as ex_model_Ar_P_LJ), but when you try to use any additional potentials installed using kim-api-collections-management, the model cannot be found.

It is not possible to cover all cases, but I hope this message will make you aware of the potential issue and present some common solutions.

This most commonly happens because you both built the KIM API from source, as well as installing it in a Conda environment (possibly unknowingly as a dependency). It can also happen if you build LAMMPS with the DOWNLOAD_KIM option (which should not be used – it is only for debugging).

The fix to both of these issues may be as easy as setting your LD_LIBRARY_PATH environment variable to the correct installation of the KIM API. Find the path to the kim-api-collections-management executable you have been using to install your models:

which kim-api-collections-management

Let’s say it’s something like /path/to/your/conda/environment/bin/kim-api-collections-management. Then the fix may be as simple as setting

export LD_LIBRARY_PATH='/path/to/your/conda/environment/lib/'

before running your program, or you can add it to your .profile, .bashrc, your Conda environment settings, etc.

As long as the program you are using was compiled for the same version of the KIM API, this is generally all you need to do. If this does not solve your problem, please read the READMEs and documentation for your simulation program, and ask in this forum if it is still unclear. For example, if your code is having trouble finding the KIM API during build time, see the following resources:
https://docs.lammps.org/Build_extras.html#kim
GULP: Item (3) in the README file for GULP 6.2

@akohlmey @relliott @julian please feel free to weigh in if you have anything to add.

1 Like

Hello,

I installed openkim as Ubuntu package

sudo add-apt-repository ppa:openkim/latest
sudo apt-get update
sudo apt-get install libkim-api-dev openkim-models

but “pip3 install kimpy” later failed due to " Exception: Package “libkim-api” was not found in the search path. Make sure “kim-api” is installed and do not forget to “source path/to/kim-api-activate”."

The command “kim-api-collections-management list” shows many empty kim-related envirovariables. Is there a bash-file for source to have all envirovariables fille ?

Hi Miroslav,

The empty environment variables in kim-api-collections-management-list is not an issue. Do you have pkg-config installed? You can install it as an Ubuntu package also if not, that may fix your issue.

1 Like

Hello,

I installed it, now its fine.

sudo apt install pkgconf

pkg-config  libkim-api-dev openkim-models

pip3 install kimpy
Defaulting to user installation because normal site-packages is not writeable
Collecting kimpy
  Using cached kimpy-2.1.1.tar.gz (50 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in /home/milias/.local/lib/python3.10/site-packages (from kimpy) (1.26.4)
Building wheels for collected packages: kimpy
  Building wheel for kimpy (pyproject.toml) ... done
  Created wheel for kimpy: filename=kimpy-2.1.1-cp310-cp310-linux_x86_64.whl size=23280193 sha256=4a119a172ed1b753b5cab304ba69e7689b3953b5a54a286b9a5ae6db43f2225c
  Stored in directory: /home/milias/.cache/pip/wheels/4a/a1/b6/42099de5d34d9eb5e7fe076fb5903221eee6b7bed67c596bcc
Successfully built kimpy
Installing collected packages: kimpy
Successfully installed kimpy-2.1.1
1 Like