Installation of LAMMPS with GPU package

Installation of LAMMPS with GPU package

In the current (and later) version of LAMMPS, many external special packages, called accelerating packages, has been being developed and implemented. The aim of this package is to speed up the calculation using external devices which known as accelerator, such as graphical processing unit (GPU). Those accelerating packages includes

  • USER-OMP (best for Intel Xeon Phi with 2 - 4 threads)
  • USER-INTEL (best and work well with Intel Xeon cluster, such as KNL series)
  • KOKKOS (For Nvidia, OpenMP threading and Intel Xeon)
  • GPU (support both Nvidia and OpenCL)

In this post I would like to provide and explain the way I compiled LAMMPS with GPU package which can carry out the computation on GPU card. For GPU package, the GPU architecture I used is with Tesla P100 (Pascal60 series) from Nvidia with its proprietary CUDA platform .

Content

Prerequisites

1. Intel C++ MPI compiler driver (default compiler)

2. GCC ( newer version is better)

3. CUDA toolkit. Download from https://developer.nvidia.com/cuda-downloads

4. GPU (for program testing)

Build GPU library before compile

1. Navigate to library directory of GPU package in LAMMPS directory

cd lib/gpu

2. Browse a make file called "Makefile.mpi" and edit this file as following

line 11: CUDA_HOME = /pkg/cuda/9.1.85
line 37: CUDA_LIB = -L$(CUDA_HOME)/lib64  -L$(CUDA_HOME)/lib64/stubs

I changed full path of CUDA home directory (in line 11) and added the path where its stubs library sub-directory is (in line 37).

3. Then use following command to build GPU library.

make -f Makefile.mpi -j 8

4. In my case, I waited just a second. Then I checked if gpu static library "libgpu.a" is installed.

ls *.a

5. In addition, Makefile.lammps.standard will be also created. I edited this file and correct the path of CUDA home.

vi lib/gpu/Makefile.lammps.standard

6. I also corrected the full path of CUDA directory and added its library sub-directory, for example, as following

line 5: CUDA_HOME=/pkg/cuda/9.1.85
line 10: gpu_SYSPATH = -L$(CUDA_HOME)/lib64 -L$(CUDA_HOME)/lib64/stubs

*I was using CUDA version 9 on the day I wrote this post.

Compile LAMMPS/GPU

1. Edit makefile of GPU package, "Makefile.gpu".

vi src/MAKE/OPTIONS/Makefile.gpu

2. I added directory and libcudart.so (shared-object) library, for example,

LIB =           -L/pkg/cuda/9.1.85/lib64 -lcudart
  • /pkg/cuda/9.1.85/lib64 is where libcudart.so is.
  • cudart is name of libcudart.so library.

3. Install GPU package. To make sure that GPU package is work, I installed LAMMPS with only GPU package first. If successfully without any error, I would include other packages and recompile later.

make no-all
make yes-gpu

3.1 OPTIONAL: you cak use following command to see the status of all packages.

make package-status

4. Change directory to src directory and build LAMMPS executable using command

make gpu

The command above will build LAMMPS with serial making, for parallel making, use -j N option. For example, make LAMMPS with 16 parallel cores.

make gpu -j 16

5. After finished, there will be LAMMPS executable called lmp_gpu in src directory.

ls -lh src/lmp_gpu

6. Eventually, LAMMPS executable is installed at /LAMMPS/src/lmp_gpu

Caveats

The CUDA precision in this compilation was set with following flag, this means accumulation of forces for all calculations.

CUDA_PRECISION = -D_SINGLE_DOUBLE

If you want to change to use other precision for GPU, says, -D_SINGLE_SINGLE, you must clean up the old library before building a new one, for example,

make -f Makefile.mpi clean

then change GPU precision in Makefile.mpi and re-build libgpu.a library.

make -f Makefile.mpi -j 8

Program Testing

Example of GPU calculations are available at examples/accelerate, input and output files are provided.

For example, use command below to run calculation with LJ style and utilize 1 CPU and 1 GPU.

cd examples/accelerate
../../src/lmp_gpu -sf gpu < in.lj > in.lj &

This will run LAMMPS/GPU in background. You can also check status of GPU card using nvidia-smi.

Error

/pkg/intel/2018_u1/compilers_and_libraries_2018.1.163/linux/compiler/lib/intel64/libintlc.so.5: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [../lmp_gpu] Error 1
make[1]: Leaving directory `/home/u7/u31rkk00/lammps-stable_16Mar2018/src/Obj_gpu'
make: *** [gpu] Error 2

Solution

Add -lX11 to LIB flags

Rangsiman Ketkaew