Unable to build LAMMPS with KOKKOS packkage

Hi i was recently trying to use KOKKOS but I am facing issues with compilation.
I download lammps from the lammps website, unpack it then,

cmake -C …/cmake/presets/most.cmake -C …/cmake/presets/nolib.cmake -C …/cmake/presets/kokkos-cuda.cmake -D KOKKOS=yes -DKokkos_ENABLE_CUDA:BOOL=ON -D Kokkos_ENABLE_CUDA=ON -D Kokkos_ARCH_AMPERE80=ON -D Kokkos_ENABLE_CUDA_LAMBDA=ON -D cuda_ccbindir=/opt/cuda/bin -D Kokkos_ARCH_HOSTARCH=yes -D Kokkos_ARCH_GPUARCH=yes -D Kokkos_ENABLE_CUDA=yes -D Kokkos_ENABLE_OPENMP=yes …/cmake

and then I try to build with make -j 10 but no matter what I do I get the error
nvcc warning : incompatible redefinition for option ‘compiler-bindir’, the last value of this option was used
/usr/include/x86_64-linux-gnu/bits/floatn.h(86): error: invalid combination of type specifiers
typedef __float128 _Float128;

LAMMPS Version: 20240829
Operating System: Linux Ubuntu" 22.04
CMake Version: 3.22.1

GPU: NVIDIA GeForce RTX 2080
Cuda compilation tools, release 12.3
gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0
g++ (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0

Im sorry if its a silly question but I have spent several hours and cannot find a solution

since im on a cluster i need to load the modules first

module --force purge
module load StdEnv/2023 nvhpc/25.1 openmpi/5.0.3

then this is my build command on linux:

cmake ../cmake -D BUILD_MPI=yes -D BUILD_SHARED_LIBS=yes \
    -D LAMMPS_MACHINE=kk -D CMAKE_INSTALL_PREFIX=~/local \
    -D CMAKE_CXX_COMPILER="${PWD}/../lib/kokkos/bin/nvcc_wrapper" \
    -D PKG_KOKKOS=yes -D Kokkos_ENABLE_SERIAL=yes \
    -D Kokkos_ENABLE_CUDA=yes -D FFT_KOKKOS=CUFFT \
    -D Kokkos_ARCH_NATIVE=yes -D Kokkos_ARCH_AMPERE80=yes \
    -D PKG_REAXFF=yes ; \
cmake --build . -j 40 ; make install

Don’t worry, this isn’t a silly question at all. I actually struggled with compiling the Kokkos package for almost a week myself and only recently got it working. You’re on the right track—let’s break down your two issues:

  1. “nvcc warning: incompatible redefinition for option ‘compiler-bindir’, the last value of this option was used”
    This warning occurs because the hardware flag -DKokkos_ARCH_PASCAL60 = ON is already predefined in the kokkos-cuda.cmake file. This warning is completely normal (a common occurrence when compiler options are redefined) and won’t affect your workflow. In fact, if you’re seeing this warning, it means your -DKokkos_ARCH_AMPERE80=ON command is working as intended and has successfully overridden the preset package’s configuration (which is exactly what we wanted). If you’d like to suppress the warning, you could modify the preset package directly—though this isn’t strictly necessary unless you prioritize cleaner build output.
  2. “/usr/include/x86_64-linux-gnu/bits/floatn.h(86): error: invalid combination of type specifiers typedef __float128 _Float128;”
    This is likely a header conflict: GCC 13’s new features (like _Float128 ) might not work with CUDA’s nvcc . According to the CUDA Installation Guide, CUDA 12.x officially supports only GCC 11 or Clang 14. A quick fix would be downgrading your g++.

This is the best analysis I can offer based on my experience, and I hope it helps! Please don’t hesitate to ask more questions—debugging these issues is how we all learn. You’ve got this! :muscle:

3 Likes

Hi

Thanks, Downgrading g++ actually worked!!!

1 Like