LAMMPS Kokkos GPU: cudaErrorIllegalAddress during neighbor build (NBinKokkos::bin_atoms)

I’m hitting a GPU crash when running LAMMPS with Kokkos. The error happens during neighbor construction / atom binning and aborts with cudaErrorIllegalAddress.

cudaDeviceSynchronize() error( cudaErrorIllegalAddress): an illegal memory access was encountered /home/manav/Softwares/ml/lammps/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Instance.cpp:154
Backtrace:
[0x73e31284c289] Kokkos::Impl::save_stacktrace()
[0x73e312828800] Kokkos::Impl::host_abort(char const*)
[0x73e31285278b] Kokkos::Impl::cuda_internal_error_abort(cudaError, char const*, char const*, int)
[0x73e3128529ca] Kokkos::Impl::cuda_device_synchronize(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)
[0x73e31282a11d] Kokkos::Impl::ExecSpaceManager::static_fence(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)
[0x73e311af5bb5] LAMMPS_NS::NBinKokkosKokkos::Cuda::bin_atoms()
[0x73e311a7ff9c] void LAMMPS_NS::NeighborKokkos::build_kokkosKokkos::Cuda(int)
[0x73e312103926] LAMMPS_NS::VerletKokkos::run(int)
[0x73e31182774c] LAMMPS_NS::Run::command(int, char**)
[0x73e311615afd] LAMMPS_NS::Input::execute_command()
[0x73e311615ef6] LAMMPS_NS::Input::file()
[0x58944bf775bc]
[0x73e306629d90]
[0x73e306629e40] __libc_start_main
[0x58944bf77665]
Aborted (core dumped)

Thanks a lot for any pointers!

Without context and a way to reproduce it, we have no chance to point to anything.

We need to know:

  • what is your LAMMPS version? is this “vanilla LAMMPS” or did you add any external packages not distributed as part of LAMMPS?
  • how exactly did you compile it with which settings?
  • what are your compiler and CUDA toolkit versions?
  • what is the output of lmp -h?
  • what kind of platform (OS, CPU architecture and version) are you running?
  • what kind of GPU do you have and how many per node?
  • what is your exact command line?
  • what is the specific input that triggers this error?
  • do you get the same crash when you run any of the LAMMPS benchmark or example inputs?

Thank you for your reply.

  1. My version is LAMMPS (22 Jul 2025 - Development), Branch: develop, it’s vanilla LAMMPS.
  2. cmake -C kokkos-cuda.cmake
    -D CMAKE_C_COMPILER=$MPICC
    -D CMAKE_CXX_COMPILER=MPICXX \ -D CMAKE_BUILD_TYPE=Release \ -D CMAKE_INSTALL_PREFIX=(pwd)
    -D BUILD_MPI=ON
    -D PKG_ML-IAP=ON
    -D PKG_ML-SNAP=ON
    -D BUILD_SHARED_LIBS=ON
    -D MLIAP_ENABLE_PYTHON=ON
    -D PKG_PYTHON=ON
    …/cmake
  3. Compilers / MPI
  • MPI C: Intel oneAPI MPI 2021.14
  • MPI C++: Intel MPI wrappers → GCC 11.4.0
  • C/C++ compiler used: GCC 11.4.0
    CUDA
  • CUDA toolkit (nvcc): 11.8 (V11.8.89)
  • nvidia-smi shows CUDA 12.2
  • GPU: NVIDIA L40 (46 GB)

lammps_help.txt (6.8 KB)
5. Ubuntu 22.04.5 LTS (Jammy), x86_64, Linux kernel 6.8.0-60-generic.
6. GPUs per node: 1 × NVIDIA L40.
7. command line: lmp -k on g 1 -sf kk -in myinput.in
8. my input
units metal
atom_style atomic
atom_modify map yes
newton on
read_data myfile.data
pair_style mliap unified mymodel.pt 0
pair_coeff * * C Na
timestep 0.001
thermo 100
dump myDump all custom 100 dump.mace id type x y z
dump_modify myDump sort id
fix 1 all nvt temp 300 300 100
run 1000
9. I don’t see this error on benchmarks.

Thanks again for your help!

Often this occurs when your system blows up, similar to the lost atoms or non-numeric pressure errors.

Having the same issue and it can be work around by rerun from restart file (keep original velocity)

    cmake  \
      -D DOWNLOAD_PLUMED=OFF \
      -D PLUMED_MODE=runtime \
      -D PKG_PLUGIN=ON \
      -D PKG_PLUMED=ON \
      -D PKG_MISC=ON \
      -D BUILD_MPI=ON \
      -D BUILD_OMP=ON \
      -D BUILD_SHARED_LIBS=ON \
      -D PKG_EXTRA-DUMP=ON \
      -D PKG_EXTRA-FIX=ON \
      -D PKG_EXTRA-PAIR=ON \
      -D PKG_KSPACE=ON \
      -D PKG_COMPRESS=ON \
      -D PKG_MOLECULE=ON \
      -D PKG_KOKKOS=ON \
      -D Kokkos_ENABLE_CUDA=ON \
      -D $KOKKOS_ARCH=ON \
      -D CMAKE_BUILD_TYPE=Release \
      -D CMAKE_CXX_COMPILER=$LMP_DIR/lib/kokkos/bin/nvcc_wrapper \
      -D CMAKE_INSTALL_PREFIX=$LMP_INSTALL_DIR \
      -D CMAKE_PREFIX_PATH="$DP_INSTALL_DIR;$CONDA_PREFIX" \
      ../cmake
    486600   504.10435     -331455.34      62.358696     -331392.98     -419.96188      12660.955      23.307131      23.307131      23.307131      0
         0              0
(CudaInternal::default_instance->cuda_memcpy_wrapper(dst, src, n, cudaMemcpyDefault)) error( cudaErrorIllegalAddress): an illegal memory access was encountered /public/groups/ai4ec/libs/conda/deepmd/3.2.0/src/lammps/lib/kokkos/core/src/Cuda/Kokkos_CudaSpace.cpp:46
Backtrace:
[0x1537f4f29286] Kokkos::Impl::save_stacktrace()
[0x1537f4f04650] Kokkos::Impl::host_abort(char const*)
[0x1537f4f312b5] Kokkos::Impl::cuda_internal_error_abort(cudaError, char const*, char const*, int)
[0x1537f4f2b0a0] Kokkos::Impl::DeepCopyCuda(void*, void const*, unsigned long)
[0x1537f23419f7] LAMMPS_NS::NBinKokkos<Kokkos::Cuda>::bin_atoms()
[0x1537f22b223d] void LAMMPS_NS::NeighborKokkos::build_kokkos<Kokkos::Cuda>(int)
[0x1537f2c09438] LAMMPS_NS::VerletKokkos::run(int)
[0x1537f1d34c8c] LAMMPS_NS::Run::command(int, char**)
[0x1537f1ab791b] LAMMPS_NS::Input::execute_command()
[0x1537f1ab8192] LAMMPS_NS::Input::file()
[0x56024bff4d53] main
[0x1537ef83acf3] __libc_start_main
[0x56024bff4eae] _start

I find this very similar issue so just link it here: Cuda illegal memory access(kokkos) when using multiple GPUs - LAMMPS / LAMMPS Development - Materials Science Community Discourse

Unfortunately, there are no details about the LAMMPS version and platform that you are building on and that makes it hard to add any meaningful comments on this or determine whether you are reporting an issue that has already been resolved.

Please see the sticky “Read This First” post to learn how to best describe issues.

Sorry to missing that. It’s lammps-src-4Jul2026.tar.gz and the platform is Nvidia A100. The environment is setup via the following conda command:

conda create -y -p $ENV_PATH -c conda-forge --override-channels \
    python=3.12.12 cuda-version=12.9 cmake cuda-toolkit cuda-libraries cudnn \
    openmpi compilers jpeg cython "fftw[build=*openmpi*]" "plumed[build=*openmpi*]"  gsl \
    pytorch=2.11.0=cuda129*

Please note that there are more recent LAMMPS releases, especially the stable release 30Sep2026 which already had one bugfix update, and also note that we cannot comment on conda based installations, since those builds are not maintained by the LAMMPS developers but externally.

If this is also about running pair style mliap unified then you are mostly out of luck, since this is externally contributed code and maintenance for that has been “spotty” to put it friendly.
There are currently multiple MLIAP related pull requests pending that are in need of reviewing… so you may want to update to the development version of lammps through git and try those changes out on top of that.