openkim / kim-api

The Open Knowledgebase of Interatomic Models (OpenKIM) aims to be an online resource for standardized testing, long-term warehousing and easy retrieval of interatomic models and data.
https://openkim.org
GNU Lesser General Public License v2.1
31 stars 20 forks source link

kim-api installed from source on a Rocky (RHEL clone) 8 fails to add Ercolessi Adams model #88

Open bernstei opened 1 year ago

bernstei commented 1 year ago

Following the instructions at https://openkim.org/doc/usage/obtaining-models/#installing_api to install from source, with some slight modifications, appears to work. The modifications are to set -DCMAKE_INSTALL_PREFIX=${PWD}/../../installed-kim-api-2.3.0, as the LAMMPS kim README suggests, and to skip the sudos.

Using this installation to to install the Ercolessi-Adams model that the LAMMPS README refers to leads to an error. Our /tmp is mounted noexec, which I believe will also block shared libraries. Is there a way to set a different TMPDIR, in case that's the issue?

tin 1019 : kim-api-collections-management install user EAM_ErcolessiAdams_1994_Al__MO_324507536345_002
Downloading.............. EAM_ErcolessiAdams_1994_Al__MO_324507536345_002
[  9%] Generating kimspec.edn.c
[ 18%] Generating item-compiled-with-version.txt.c
[ 27%] Generating kimcite-MO_324507536345_002.bib.c
[ 36%] Generating kimprovenance.edn.c
Scanning dependencies of target EAM_ErcolessiAdams_1994_Al__MO_324507536345_002
[ 45%] Building Fortran object CMakeFiles/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002.dir/EAM_ErcolessiAdams_1994_Al.f90.o
[ 54%] Building C object CMakeFiles/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002.dir/item-compiled-with-version.txt.c.o
[ 63%] Building C object CMakeFiles/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002.dir/kimcite-MO_324507536345_002.bib.c.o
/tmp/kim-api-build-6GCR1fgKoR/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002/EAM_ErcolessiAdams_1994_Al.f90:1017:46:

 1017 |   requested_energy_unit, requested_charge_unit, requested_temperature_unit, &
      |                                              1
Warning: Unused dummy argument ‘requested_charge_unit’ at (1) [-Wunused-dummy-argument]
/tmp/kim-api-build-6GCR1fgKoR/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002/EAM_ErcolessiAdams_1994_Al.f90:1017:23:

 1017 |   requested_energy_unit, requested_charge_unit, requested_temperature_unit, &
      |                       1
Warning: Unused dummy argument ‘requested_energy_unit’ at (1) [-Wunused-dummy-argument]
/tmp/kim-api-build-6GCR1fgKoR/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002/EAM_ErcolessiAdams_1994_Al.f90:1016:70:

 1016 | recursive subroutine create(model_create_handle, requested_length_unit, &
      |                                                                      1
Warning: Unused dummy argument ‘requested_length_unit’ at (1) [-Wunused-dummy-argument]
/tmp/kim-api-build-6GCR1fgKoR/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002/EAM_ErcolessiAdams_1994_Al.f90:1017:74:

 1017 |   requested_energy_unit, requested_charge_unit, requested_temperature_unit, &
      |                                                                          1
Warning: Unused dummy argument ‘requested_temperature_unit’ at (1) [-Wunused-dummy-argument]
/tmp/kim-api-build-6GCR1fgKoR/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002/EAM_ErcolessiAdams_1994_Al.f90:1018:21:

 1018 |   requested_time_unit, ierr) bind(c)
      |                     1
Warning: Unused dummy argument ‘requested_time_unit’ at (1) [-Wunused-dummy-argument]
[ 72%] Building C object CMakeFiles/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002.dir/kimprovenance.edn.c.o
[ 81%] Building C object CMakeFiles/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002.dir/kimspec.edn.c.o
[ 90%] Building CXX object CMakeFiles/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002.dir/item-wrapper.cpp.o
[100%] Linking CXX shared module libkim-api-portable-model.so
[100%] Built target EAM_ErcolessiAdams_1994_Al__MO_324507536345_002
Running tests...
Test project /tmp/kim-api-build-6GCR1fgKoR/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002/build
    Start 1: shared_library_test_EAM_ErcolessiAdams_1994_Al__MO_324507536345_002
1/1 Test #1: shared_library_test_EAM_ErcolessiAdams_1994_Al__MO_324507536345_002 ...***Failed    0.00 sec
Unable to open shared library.
/tmp/kim-api-build-6GCR1fgKoR/EAM_ErcolessiAdams_1994_Al__MO_324507536345_002/build/libkim-api-portable-model.so: failed to map segment from shared object

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.00 sec

The following tests FAILED:
          1 - shared_library_test_EAM_ErcolessiAdams_1994_Al__MO_324507536345_002 (Failed)
Errors while running CTest
make: *** [Makefile:71: test] Error 8

Aborting!
tin 1020 : 
ellio167 commented 1 year ago

The kim-api uses the c++ standard routine std::filesystem::temp_directory_path() (https://en.cppreference.com/w/cpp/filesystem/temp_directory_path). So this is, logically, not a kim-api issue but an issue with your system. I guess the fix will depend on your system's implementation of the c++ standard. Yes, I would guess that you can use TMPDIR to put your system into working order.

bernstei commented 1 year ago

I don't think it's obvious that it's an issue with our system as such, because the directory is created. It's only a problem because of KIM's assumption that a directory created this way is an acceptable place to put a shared library to be dynamically loaded. I realize it's not the most common configuration, but it's not a crazy one.

Setting TMPDIR does fix the issue. I think at the very least it could use a note in the docs someplace.

ellio167 commented 1 year ago

Actually, looking deeper, there are other places in collections-management scripts that just use TMPDIR directly.
https://github.com/openkim/kim-api/blob/431e641788a5df5ff6058e1974004c7efe93931e/utils/collections-management.in#L205

And we have a std::filesystem drop-in replacement for older compilers https://github.com/openkim/kim-api/blob/431e641788a5df5ff6058e1974004c7efe93931e/cpp/src/ghc-filesystem/filesystem.hpp#L4598 that will use TMPDIR first and then check other env variables if it's not defined.

So, yes, I think setting TMPDIR is the best solution here.

ellio167 commented 1 year ago

Ah, OK now I understand more clearly: the system provides /tmp but doesn't allow (direct) execution of files created there. Yeah, that's an issue.

It seems that the C++ standard doesn't say anything about the permissions of the returned temp directory; POSIX doesn't require systems to provide TMPDIR.

So, yeah, it seems that the best that can be done is to document the expectations of the kim-api:

We'll leave this issue open as a reminder to implement this addition to the documentation.

bernstei commented 1 year ago

Sounds good.