build instructions (Makefiles) for ubuntu, gpu(cuda) and gpu(opencl)

I noticed that "Makefile.ubuntu_parallel" is not in src/MAKE (for the
lammps-12Apr13 version).

Anyway, if you are having trouble building LAMMPS on ubuntu (with or
without GPU acceleration), here are some makefiles which may help.
(See attached.) They have been tested on Nvidia TESLA, and AMD Radeon
5xxx cards. (See the comment section in each Makefile for details.)

For this to work, you must have the following debian packages
installed on your system: build-essential, fftw-dev, mpich2, gfortran.
You can install them using:

sudo apt-get build-essential fftw-dev mpich2 gfortran

----- Makefiles in src/MAKE ------
Copy these Makefiles to your "src/MAKE" directory:


  -------- file ----------------|------- compatible with --------

Makefile.ubuntu_parallel = Ubuntu 12.10, mpicxx (g++),
                                      MPICH2 1.2, FFTW 2.1.3
                                      no GPU acceleration

Makefile.ubuntu_dbg = same, but with -g and -O0 flags

Makefile.ubuntu_gpu_cuda = Ubuntu 12.04 64bit, mpicxx (g++),
                  MPICH2 1.2, FFTW 2.1.3, CUDA 4.2 (5 works too)

Makefile.ubuntu_gpu_opencl_amd = Ubuntu 12.10 64bit,
                              mpicxx (g++), MPICH2 1.2,
                              FFTW 2.1.3, AMD OpenCL SDK 2.8

----- basic LAMMPS compilation -----

To compile a version of LAMMPS without GPU acceleration:
go to the "src" directory and type:

make clean-all
make ubuntu_parallel

------ GPU acceleration ------

To enable GPU acceleration,
go to the "lib/gpu" directory and follow the instructions to build
libgpu.a (see below)

Then ho to the "src" directory, and run:

make clean-all
make yes-gpu

make ubuntu_gpu_opencl_amd
  - OR -
make ubuntu_gpu_cuda

For this to work, you may need to update your LD_LIBRARY_PATH
environment variable beforehand. If compilation fails during linking,
see the instructions for doing this below.

----- To build libgpu.a -----

Copy these (attached) Makefiles to your "lib/gpu" directory:


If you did not install CUDA or OpenCL in the standard location, then
open up all of the Makefiles with a text editor and correct the
"CUDA_HOME" or "OPENCL_HOME" variables.

Then you can create "libgpu.a" using one of the following commands:
make -f Makefile.linux_cuda
   - OR -
make -f Makefile.linux_opencl_amd

(Also, if this is not the first time you compiled LAMMPS, then run
this beforehand:
rm -f *.o libgpu.a)

------- LD_LIBRARY_PATH ------

To enable GPU acceleration, I also had to edit my ~/.bashrc file and
append one of these lines to it:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
# ...if you are using CUDA which is installed in the default location.

  - OR -

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/AMDAPP/lib/x86_64"
# ...if you are using AMDs OpenCL installed in the default location.

At the moment, it seems that you have to put this line in your ~/.bashrc file.
(... because of this bug:

I hope this is handy to someone out there.
I hope I did not leave anything out.



Makefile.ubuntu_parallel (815 Bytes)

Makefile.ubuntu_dbg (811 Bytes)

Makefile.ubuntu_gpu_cuda (1.56 KB)

Makefile.ubuntu_gpu_opencl_amd (1.44 KB)

Makefile.linux_cuda (1.08 KB)

Makefile.linux_opencl_amd (562 Bytes)

(sorry this should have been)

sudo apt-get install build-essential fftw-dev mpich2 gfortran

Another quick correction:
It appears that ubuntu now installs openmpi by default. So it's not
necessary to install mpich2. (And in fact, you may have problems if
you do.) Instead, on a newly installed computer I suggest NOT
installing mpich2. Instead just use:

sudo apt-get install build-essential fftw-dev gfortran

I was having difficulty getting MPI to work recently, and uninstalling
mpich2 fixed the problem.
I hope this helps somebody.

Please post any corrections you find.