Guide · LAMMPS · 12 min read
How do I install or compile LAMMPS?
Checked against the docs · LAMMPS stable release 30 Sep 2026 · Last checked 11 November 2026 · Spot a mistake? Tell us
Short answer
Check first what your cluster already has: load its LAMMPS module and run lmp -h, which lists the packages that build includes. Build your own only when none has what you need, from the LAMMPS source with CMake, turning on each package your potential needs; the result is an executable called lmp.
What does "installing LAMMPS" mean?
LAMMPS is one program, an executable: a file you run, such as lmp, that reads your input script and runs the simulation. There are two ways to get one. You can use an executable someone else built (your cluster's, a Linux package, a Conda package), or you can compile it yourself: turn the LAMMPS source code into an executable on the machine where it will run.
What an executable can do depends on how it was built. LAMMPS is split into packages, groups of files that add a set of features: the MANYBODY package holds many-body potentials such as EAM and Tersoff, KSPACE long-range electrostatics, REAXFF the ReaxFF potential, KOKKOS and GPU the versions that run on graphics cards. The manual's Include packages in build page puts it plainly: by default no packages are installed, and a command whose package was left out of the build is not there at all.
Two more choices are made when LAMMPS is built:
- MPI (the Message Passing Interface) is the library that lets one LAMMPS run spread over many processor cores and many nodes, each MPI process (or rank) working on its own region of the simulation box. A build without it is a serial executable that runs on one core.
- OpenMP threading lets several threads inside one MPI process share its work. It is turned on per package, mostly through the
OPENMPpackage.
Do I need to compile LAMMPS at all?
Often not. The manual's Install page describes the trade: a pre-built executable is quick, but you get the version and the packages its builder chose; building from source lets you choose them, and is the only way if you will change or extend LAMMPS.
On a cluster, look for a module first. Most clusters install software as environment modules, which you load into your shell before you run. The manual uses the same commands to look for CMake:
module list # what is loaded now
module avail # what modules existYour cluster's user guide says what its LAMMPS modules are called and which one to load. The cluster's administrators built that executable for its hardware and its MPI, so when it has the packages you need, it is usually the one to use. The manual notes that a vendor's or administrator's MPI on a large machine is likely to be faster than one you install yourself.
Pre-built executables outside the cluster. The manual lists several (Download an executable for Linux, Conda): static Linux executables that run on any 64-bit x86 Linux and include most packages and threading, but are not compatible with MPI, so they do not run across nodes; packages for Ubuntu, Debian, Fedora and other distributions; and a Conda package, built with the KIM package for OpenKIM potentials. The manual is clear that questions about these go to the people who prepared them, not to the LAMMPS developers, and that they may lag behind new releases.
Build your own when:
- the potential you have chosen needs a package no available build has (an ML potential's package,
REAXFF,KIM); - you need a GPU build for your cluster's cards, or a different precision;
- you need a newer version than the cluster has, or you will change the code.
What does my cluster's LAMMPS already include?
Load the module (or point at the executable) and ask it:
lmp -hThe -help switch prints a short help summary and the list of styles compiled into this executable, for every kind of command (atom_style, fix, compute, pair_style and the rest), then exits without running anything. The manual's packages page adds that it lists all optional commands and packages enabled when that executable was built. With compressed file support built in, it also lists the compression formats it can read and write (Optional build settings).
So if your potential is pair_style eam/alloy, look for eam/alloy in the pair styles; for ReaxFF, reaxff; for a GPU run, the styles with a /gpu or /kk ending. The executable's name may differ: an executable built with CMake is called lmp unless the builder set a machine name, in which case it is lmp_<name> (lmp_mpi, lmp_kokkos_cuda), and builds with the older make system are always lmp_<machine> (Basic build options).
How do I compile LAMMPS with CMake?
CMake is the build system the manual calls the preferred way, and the developers plan to retire the older make-based one (Build LAMMPS). The commands below follow the manual's Build LAMMPS with CMake and Include packages in build pages.
1. Get the source. Either a tarball of the current stable release from the LAMMPS download page (Tarball), or the git repository (git). The stable release gets more testing before it is published; feature releases come every 4 to 8 weeks. The full git history is large; a shallow clone saves disk space (Saving disk space):
git clone -b stable --depth 10000 https://github.com/lammps/lammps.git mylammpsThe manual says a depth of up to 10000 may be needed to include the head of the stable branch.
2. Load what the build needs. CMake 3.20 or later, a C and C++ compiler that supports C++17, and an MPI library for a parallel build (Prerequisites). On a cluster these come as modules too; check with cmake --version.
3. Configure, in a separate build folder. CMake keeps everything it generates out of the source tree, so you can have several builds side by side:
cd mylammps
mkdir build
cd build
cmake -C ../cmake/presets/basic.cmake -D PKG_MANYBODY=yes ../cmake-C ../cmake/presets/basic.cmake loads a preset, a file of settings; basic turns on a few core packages (MOLECULE, KSPACE, MANYBODY, RIGID, GRAPHICS), and most turns on most of them. Each -D PKG_NAME=yes adds one package, by its name in capitals. ../cmake is the folder that holds LAMMPS's CMake scripts. At the end CMake prints a summary of the compilers, flags and packages it will use; the manual asks you to read it and confirm they are the ones you want. CMake looks for MPI and builds with it by default when it finds it (-D BUILD_MPI=no forces a serial build), and turns OpenMP on when the compiler supports it.
4. Compile.
cmake --build . --parallel 8--parallel 8 compiles 8 files at a time (an example; use the cores you have). Compiling takes a while: LAMMPS is a large program. Whether you may compile on the login node is your cluster's rule, not the manual's; check its user guide, which may ask you to compile inside an interactive job instead. The result is an executable lmp in the build folder, and the library liblammps.a beside it.
5. Optionally, install it. cmake --install . copies the executable, the library and the potential files into $HOME/.local by default. Otherwise, give the executable's full path in your job script.
To add a package later, run CMake again in the same folder with the new -D PKG_NAME=yes and compile again; only what changed is rebuilt.
Accelerators: GPUs and threads. LAMMPS has five accelerator packages (Accelerator packages). Their styles have the same names as the plain ones with a suffix (lj/cut/gpu, lj/cut/kk, lj/cut/omp), give the same results apart from precision and round-off, and are switched on when you run, with -sf (and -k on for KOKKOS). For the common hardware, choose yours:
| Your nodes | Build with | Why |
|---|---|---|
| CPUs, MPI only | the packages your potential needs, MPI on | CMake builds with MPI by default when it finds an MPI library. Run with mpiexec -np 4 lmp -in in.file (the manual's example; on a SLURM cluster, the launch line your cluster's guide gives). |
| CPUs, MPI and threads | -D PKG_OPENMP=yes | The OPENMP package needs nothing else when CMake detects OpenMP support in the compiler. Run its styles with -sf omp and set the threads per MPI process with -pk omp 4, as in the manual's mpirun -np 4 lmp_omp -sf omp -pk omp 4 -in in.script (an executable named lmp_omp). |
| NVIDIA GPUs, KOKKOS | the kokkos-cuda preset | The manual's example for CUDA. KOKKOS must be told the CPU and GPU architecture it is for, and may need its preset edited for your cards; one executable cannot hold more than one GPU back end (CUDA, HIP, SYCL). Run with -k on -sf kk and the number of GPUs per node after g: the manual runs two MPI processes on a node with two GPUs as mpirun -np 2 lmp_kokkos_cuda_openmpi -k on g 2 -sf kk -in in.lj, with its executable named for the build. |
| GPUs, the GPU package | -D PKG_GPU=yes -D GPU_API=cuda | GPU_API is opencl (the default), cuda or hip; GPU_ARCH names the card, sm_80 or sm_86 for NVIDIA Ampere (an example: the manual lists the value for each generation); GPU_PREC is mixed by default. Run with -sf gpu -pk gpu 1, the manual's example of one MPI process using one GPU. |
What it depends on:
- Your potential. It decides which packages you need; each
pair_stylepage names its package under Restrictions (see How do I choose and cite an interatomic potential?). - Your hardware. GPUs need
KOKKOSorGPUbuilt for their architecture; the KOKKOS, GPU and OPENMP pages say how to run each. Which is fastest depends on your problem; the manual says there is no substitute for trying them on your hardware. - The packages with extra steps. Some need a library downloaded or found first; the Packages with extra build options page lists what each needs.
How do I know my build works?
Ask it what it has. lmp -h from the new build should list the packages and styles you asked for.
Run an example. LAMMPS ships with input scripts in its examples and bench folders; the sample outputs beside them are named log.*.P, where P is the number of processors they ran on (Basics of running LAMMPS). Run one that uses your potential's style, on the cores you will use, and compare its thermodynamic output with the sample log. The manual warns that runs on different numbers of processors or different machines can drift apart after a few hundred or a few thousand steps from round-off alone, while their averages (energy, temperature) should agree (Common issues). Exact agreement over the first steps and matching averages later are what to look for.
Read the end of the log. After a run, the log reports the loop time, a Performance: line (in ns/day and hours/ns, among others) and a CPU use line, which should be close to 100% times the number of OpenMP threads (Screen and logfile output). Far lower suggests threads that are not being used.
What goes wrong when building LAMMPS?
These are the problems the manual itself names.
| Mistake | What you would see | What to do |
|---|---|---|
| A style is missing from your build | LAMMPS stops with an error that the style is unknown or invalid ("Invalid … style"); for a style in a package of the distribution, the message names the package. | Run lmp -h; rebuild with -D PKG_NAME=yes for the missing package, or load a module that has it. |
| CMake older than 3.20, or a compiler without C++17 | CMake stops at the configure step with an error. | Load newer cmake and compiler modules (cmake --version). |
| Mixing the make build and CMake in one source tree | CMake detects packages installed in src by a make build and stops with an error. | Run make no-all purge in src, or start from a clean copy. |
An MPI that adds link-time optimization (-flto), as some Linux distributions' do | The link step fails, for example with KOKKOS and CUDA, with errors mentioning fatbinData or lto-wrapper. | Run CMake again in the same build folder with -D MPI_CXX_COMPILE_OPTIONS="", then build again. It has no effect on the first CMake run in a new folder. |
| A compiler with strict OpenMP 4.0 semantics | Compilation with OpenMP fails. | Add -D LAMMPS_OMP_COMPAT=4 to the CMake command line. |
A KOKKOS GPU build run on a different GPU generation | A delay at start-up while kernels are recompiled for a minor version difference; for a different major version, LAMMPS stops with an error about the mismatch. | Build for the architecture of the cards your jobs run on. |
COMPRESS with an old Zstandard library | The build fails to compile; zstd must be version 1.4 or later. | Load a newer zstd, or leave COMPRESS out. |
| The static pre-built executable on several nodes | It is not compatible with MPI. | Use a cluster module or your own MPI build for runs across nodes. |
| A restart file read by another build | The binary restart format is meant to be read by the same executable on the same platform; a different version or build may not read it, or may read it wrongly (read_restart). | Finish a series of runs with one build, or convert with lmp -restart2data using the executable that wrote the file. |
| Compressed dumps on a fast cluster network | The /gz styles need COMPRESS; gzip through a pipe uses fork(), which on some high-speed networks makes runs hang or crash (Optional build settings). | Build with COMPRESS and use the /gz or /zstd dump styles (dump). |
| An LLVM-based Intel compiler at high optimization | The manual reports versions that produce wrong results, with no simple way to detect it. | Compile with GCC or Clang unless you need the Intel compilers; if you do, keep a GCC or Clang build to check results against. |
If a compile fails for another reason, the manual's first suggestion is to run CMake again on the build folder and compile again.
Going further
Several builds from one source. Because CMake builds out of the source tree, you can keep a CPU build and a GPU build side by side in two folders. Name them with -D LAMMPS_MACHINE=name so the executables differ (lmp_cpu, lmp_gpu).
Precision on GPUs. The GPU package offers single, mixed (the default) and double precision; KOKKOS offers -D KOKKOS_PREC=double (the default), mixed or single. The manual asks that a reduced-precision run be checked carefully, energy conservation in particular, and says it works best for homogeneous bulk systems, where errors cancel best.
Threads and ranks. With OPENMP you set the threads per MPI process with OMP_NUM_THREADS or -pk omp N; the manual also points out that binding each MPI process to its cores (--bind-to core in Open MPI, -bind-to core in MPICH) can matter when it is not the default. How many ranks and threads suit a node is a question of measurement, covered in How do I use my cores well?