Transition from API v1 to v2

Hello,

I have already openkim API v1 installed on my desktop. In order to transit from API v1 to v2, I have to go through this long procedure: https://openkim.org/kim-api/docs/porting_content_from_v1_to_v2.html

Isn’t there a simpler way to switch from API v1 to v2? Isn’t just reinstalling openkim API v2 simpler?

Thanks,
Alireza

Hi Alireza,

Thanks for your message!

No! Definitely, you don't need to go through all those steps...

The "Guide for porting content from KIM API v1 to v2" document is meant for developers who have a code that is written for v1 and want to revise and update it to work with v2.

If you just want to use kim-api-v2 and any available models written for v2, then you can simply follow the build and install instructions for kim-api-v2 and everything should work OK.

There is no problem with having both v1 and v2 installed at the same time.

Let me know if you have any other questions or any trouble getting this to work.

Cheers,

Ryan

Hi Ryan,

Thanks for the quick response! If we can have both API v1 and v2 installed at the same time, then how does a simulator know which API should be used?

Regards,
Alireza

Hi Alireza,

That will depend on the simulator. Since the v2 is not backward compatible, the simulator developers need to decide if they will support v1, v2, or both. This is all a little like the python2, python3 situation. However, we expect to affect a full transition to v2 much more quickly than the ongoing transition to python3... Our advice for simulator developers is generally to aim to support v2, and not worry about continued support of v1. We are currently hard at work on converting all of the openkim.org content to v2.

Ryan

Thanks Ryan for the hard work! I followed your advice and installed both versions v1 and v2 at the same time. However when I try to install a particular model, with:

kim-api-v2-collections-management install system --sudo EDIP_BOP_Bazant_Kaxiras_Si__MO_958932894036_001

it says:

EDIP_BOP_Bazant_Kaxiras_Si__MO_958932894036_001 found at openkim.org is not compatible with this version of the KIM API.

Where can I found which models/model drivers are compatible with API v2?

Thanks,
Alireza

Hi Alireza,

Great! Right, currently the only available v2 models are the examples that come with the kim-api-v2 package (see the kim-api-v2*/examples/README file).

At the moment, all content at openkim.org is v1 compatible. We are working to convert all the openkim.org content and when it is ready we will roll out a whole-sale conversion from v1 to v2 (the v1 models will still be available, but they will be superseded by new versions that are compatible with v2). We want to complete this transition as soon as possible. We're hoping for just another few weeks to a month, but there can always be surprises.

Ryan

Thanks Ryan! Even example models throw error:

$ printf “ex_model_Ar_P_Morse” | ./utility_forces_numer_deriv

Please enter a valid KIM model name:

VERIFICATION CHECK: NUMERICAL DERIVATIVE VERIFICATION OF FORCES

Thanks Ryan! Even example models throw error:

$ printf "ex_model_Ar_P_Morse" | ./utility_forces_numer_deriv

Please enter a valid KIM model name:

VERIFICATION CHECK: NUMERICAL DERIVATIVE VERIFICATION OF FORCES

------------------------------------------------------------------------------------------------------------------------

This is Test : vc_forces_numer_deriv

Results for KIM Model : ex_model_Ar_P_Morse

* Error : 'kim_api_create' 890 :utility_forces_numer_deriv.F03

I'm afraid this is not enough information for me to determine what is going wrong. Is there a "kim.log" file that is generated when you execute this command? If you can attache that log, I might get a better idea of the problem.

I want to develop an openkim NN model in fortran. Mingjian introduced me
this example:
https://openkim.org/kim-api/docs/ex__model__driver___p___l_j_8_f90_source.html
to look at. This is compatible with API v1, right? Then maybe at this point
I should not worry about v2 and just stick to v1. Later on, I will try
converting v1-consistent to v2-consistent. Is that something you would also
suggest?

No, this is a v2 compatible example.

BTW, looking into this model (
https://openkim.org/kim-api/docs/ex__model__driver___p___l_j_8_f90_source.html),
it is not clear for me as a driver developer which subroutines I should
code and which I should not touch and just copy and paste to my model
driver. It would be nice if there were some sort of template model drivers
and template models that a developer could make use of when coding a new
model/model driver. Do you have any suggestion which subroutines I should
code up and which I should not touch?

I agree. I plan to create these minimal empty template files when I get a chance. (There is a lot of documentation that still needs to be created! Sorry that we don't have everything ready right now...)

I'll put together a first draft of this for Fortran as soon as I can (today) and send it out.

In the mean time, keep aking questions! I'll do my best to keep up and respond quickly to keep you going.

Ryan

Thanks Ryan!

​The​ kim.log file says:

2018-07-24:19:56:29+0000 * 1 * error * 0x1309cf0 *
KIM_ModelImplementation.cpp:1883 * Could not open model shared library.

This is I guess somehow related to the libkim-api-v2.so path. I have
already done:

$ LD_LIBRARY_PATH=LD\_LIBRARY\_PATH:/usr/local/lib/ export LD_LIBRARY_PATH

and am surprised it still cannot find the path of libkim-api-v2.so!

No, it's not about the finding the library. I think that is working just fine.

You may have not installed the v2 version of this model. You can get a listing
of the models and drivers that the kim-api can find with a command like:

$ kim-api-v2-collections-management list

You'll note that this will generally be different from the list provided by

$ kim-api-v1-collections-management list

​Okey, thanks! Then I will wait to start off from the draft you send me.
Take your time.​

I've just posted the template files in new thread on this mailing list.

Cheers,

Ryan

Hi Ryan,

Thanks for posting the toy model templates. They are great as starting point. I decided to start with installing the toy model on API v2. I did the followings:

$ cd /usr/local/lib/kim-api-v2/model_drivers/toy_model_driver

$ sudo make

and it throws the error:

/usr/local/libexec/kim-api-v2/kim-api-v2-collections-info: error while loading shared libraries: libkim-api-v2.so: cannot open shared object file: No such file or directory

/usr/local/libexec/kim-api-v2/kim-api-v2-collections-info: error while loading shared libraries: libkim-api-v2.so: cannot open shared object file: No such file or directory

/usr/local/lib/kim-api-v2/build_system/Makefile.ModelDriver:149: *** Invalid config file. Stop.

However, I can do:

$ kim-api-v2-collections-management list

and it works as:

Knowledgebase of Interatomic Models (KIM) — Model Collections Listing

Hi Alireza,

I think this is an issue with using the 'sudo make' command. I believe that by default the root user does not have /usr/local stuff on its PATH or library path. This is to avoid root running user installed software.

There should not be a need to run 'make' with sudo. You should be able to do:

cd /usr/local/lib/kim\-api\-v2/model\_drivers/toy\_model\_driver make
$ sudo make install-system

Alternatively you should also be able to do:

cd kim-api-v2-collections-management install system --sudo /usr/local/lib/kim-api-v2/model_drivers/toy_model_driver

Ryan

The alternative approach does not throw any error (just a couple of warnings):

Cleaning… Model Driver… toy_model_driver.

Creating… toy_model_driver.o.

toy_model_driver.F90:220.40:

model_compute_arguments_destroy_handle, ierr) bind©

1

Warning: Unused dummy argument ‘model_compute_arguments_destroy_handle’ at (1)

toy_model_driver.F90:219.63:

subroutine model_compute_arguments_destroy(model_compute_handle, &

1

Warning: Unused dummy argument ‘model_compute_handle’ at (1)

toy_model_driver.F90:190.62:

subroutine model_compute_arguments_create(model_compute_handle, &

1

Warning: Unused dummy argument ‘model_compute_handle’ at (1)

Creating… intermediate file… driver_init_wrapper.cpp.

Creating… driver_init_wrapper.o.

Creating… libkim-api-model-driver-v2.0.0-beta.1+GCC.linux.64bit.dynamic-load.a.

Creating… intermediate file… export-list.txt.

Creating… libkim-api-model-driver-v2.0.0-beta.1+GCC.linux.64bit.dynamic-load.so.

Creating… libkim-api-model-driver-v2.so.

rm driver_init_wrapper.cpp export-list.txt

Aborting!

But it aborts without installing the model driver. When I do:

$ kim-api-v2-collections-management list

I still see no model being installed:

Knowledgebase of Interatomic Models (KIM) — Model Collections Listing

Hi,

The warnings are expected, and should not cause a problem. I don't know why it is aborting. I'm not seeing that behavior on ubuntu. Do you have some extra compiler flags set that would cause warnings to be promoted to errors? like '-Werror' or '-pedantic-errors'?

Ryan

No I am not setting any extra flag for CFLAGS or CXXFLAGS. I use exactly the same Makefile as you sent me.

Hi Alireza,

OK....

can you do the following and provide the output?

cd toy\_model\_driver make

I expect that you will see the warnings again. But, in particular, I'm wondering if this 'make' command will exit with a non-zero (error) return status. To see this clearly you could use this command:

make clean if make; then printf "STATUS: SUCCESS\n"; else printf "STATUS: ERROR\n"; fi

Another thing that might be helpful is the output of this command:

make clean make QUELL=

Ryan

Hi Ryan,

There is some issue with my installation. This is the output of these commands:

$ pwd

/usr/local/lib/kim-api-v2/model_drivers/toy_model_driver

$ make

Creating… toy_model_driver.o.

toy_model_driver.F90:237.27:

end module toy_model_driver

1

Fatal Error: Can’t open module file ‘toy_model_driver.mod0’ for writing at (1): Permission denied

make: *** [toy_model_driver.o] Error 1

$ sudo make

/usr/local/libexec/kim-api-v2/kim-api-v2-collections-info: error while loading shared libraries: libkim-api-v2.so: cannot open shared object file: No such file or directory

/usr/local/libexec/kim-api-v2/kim-api-v2-collections-info: error while loading shared libraries: libkim-api-v2.so: cannot open shared object file: No such file or directory

/usr/local/lib/kim-api-v2/build_system/Makefile.ModelDriver:149: *** Invalid config file. Stop.

$ make clean

Cleaning… Model Driver… toy_model_driver.

$ if make; then printf “STATUS: SUCCESS\n”; else printf “STATUS: ERROR\n”; fi

Creating… toy_model_driver.o.

toy_model_driver.F90:237.27:

end module toy_model_driver

1

Fatal Error: Can’t open module file ‘toy_model_driver.mod0’ for writing at (1): Permission denied

make: *** [toy_model_driver.o] Error 1

STATUS: ERROR

Regards,
Alireza

Ah ha!

You should place the model driver source directory somewhere else, where you have full write access. Try:

$ mv /usr/local/lib/kim-api-v2/model_drivers/toy_model_driver ~/toy_model_driver

Then,

cd cd toy_model_driver
$ make

If that works, then you should be able to do:

cd kim-api-v2-collections-management install system —sudo ./toy_model_driver

And it will work. (When this works, it will copy the resulting compiled shared library to the /usr/local/lib/kim-api-v2/model_drivers/toy_model_driver location for you.)

Ryan

Ah!

$ make

Creating… toy_model_driver.o.

toy_model_driver.F90:220.40:

model_compute_arguments_destroy_handle, ierr) bind©

1

Warning: Unused dummy argument ‘model_compute_arguments_destroy_handle’ at (1)

toy_model_driver.F90:219.63:

subroutine model_compute_arguments_destroy(model_compute_handle, &

1

Warning: Unused dummy argument ‘model_compute_handle’ at (1)

toy_model_driver.F90:190.62:

subroutine model_compute_arguments_create(model_compute_handle, &

1

Warning: Unused dummy argument ‘model_compute_handle’ at (1)

Creating… intermediate file… driver_init_wrapper.cpp.

Creating… driver_init_wrapper.o.

Creating… libkim-api-model-driver-v2.0.0-beta.1+GCC.linux.64bit.dynamic-load.a.

Creating… intermediate file… export-list.txt.

Creating… libkim-api-model-driver-v2.0.0-beta.1+GCC.linux.64bit.dynamic-load.so.

Creating… libkim-api-model-driver-v2.so.

rm driver_init_wrapper.cpp export-list.txt

$ kim-api-v2-collections-management install system --sudo ./toy_model_driver

Enter Password :

Item ‘toy_model_driver’ already installed in collection ‘CWD’.

I did kim-api-v2-collections-management remove-all but did not fix it! How should I uninstall from collection ‘CWD’?

Regards,
Alireza

Great, that's progress.

The CWD collection is a bit of a special case. You should just do a make clean:

cd \~/toy\_model\_driver make clean
cd kim-api-v2-collections-management install system --sudo ./toy_model_driver

Ryan