Install LAMMPS for run on GPU

Hello Dear LAMMPS users
I was using the following commands to install Lammps on Linux to run on GPU, but apparently this package has not been updated and I encountered errors:

sudo add-apt-repository ppa:gladky-anton/lammps
sudo add-apt-repository ppa:openkim/latest
sudo apt update

sudo apt-get install lammps-stable lammps-stable-doc lammps-stable-data openkim-models

Please suggest the easiest way to install the prebuilt version of Lammps for GPU run.

I don’t know any. You will have to compile LAMMPS from source and configure it for your specific needs and hardware.

To add on @akohlmey comment,

GPU related packages of LAMMPS contain parts written in Cuda, and if you want to compile cuda, you have to do so with driver settings that will depend on your GPU hardware. As such it is nearly impossible to make pre-compiled executable for generic hardware that will include compatible GPU code.

Please find more info on how to compile LAMMPS in the dedicated section of the manual. You will also find more information on how to set the GPU compilation related options here and here. Note also that you’ll find information on how to determine your hardware settings and install cuda compilers that are required for compilation in the latter link.

It can be done for the GPU package. In fact, the default mode of the CMake config is to tell nvcc to compile for all supported hardware generations so all GPU kernels are compiled multiple times.

For the GPU package you can have even greater portability by configuring it for use with OpenCL. Then the compilation of the GPU kernels happens are run time. This is how OpenCL works and it requires a proper configuration of OpenCL support with an ICD (i.e. an Installable Client Driver) which is loaded by the OpenCL framework dynamically. This way, the same executable can support GPUs from Nvidia, AMD, and Intel.

For the KOKKOS package, however, there is no OpenCL support and one has to explicitly set to use CUDA and select the matching hardware. Otherwise it will just fail. For certain configurations CUDA will try to recompile all existing kernels for the current platform, but that just takes a long time and usually ends with a crash as well (at least in my tests a couple years ago).

The more you know. I didn’t know you could compile several times with different options each times for a single executable, but I guess this adds works to maintain and weight on the final package. I struggled with KOKKOS compilation on different machines more, so I had both in mind when I only mentioned the GPU package, since it was the topic of discussion. Thank you for the correction.