Merge branch 'maint'
[hoomd-blue.git] / doc / user / compile_guide_linux_generic.dox
blob39d110875e491d23e1d2fd88f43fbefc525aabcf
1 /*
2 Highly Optimized Object-oriented Many-particle Dynamics -- Blue Edition
3 (HOOMD-blue) Open Source Software License Copyright 2009-2014 The Regents of
4 the University of Michigan All rights reserved.
6 HOOMD-blue may contain modifications ("Contributions") provided, and to which
7 copyright is held, by various Contributors who have granted The Regents of the
8 University of Michigan the right to modify and/or distribute such Contributions.
10 You may redistribute, use, and create derivate works of HOOMD-blue, in source
11 and binary forms, provided you abide by the following conditions:
13 * Redistributions of source code must retain the above copyright notice, this
14 list of conditions, and the following disclaimer both in the code and
15 prominently in any materials provided with the distribution.
17 * Redistributions in binary form must reproduce the above copyright notice, this
18 list of conditions, and the following disclaimer in the documentation and/or
19 other materials provided with the distribution.
21 * All publications and presentations based on HOOMD-blue, including any reports
22 or published results obtained, in whole or in part, with HOOMD-blue, will
23 acknowledge its use according to the terms posted at the time of submission on:
24 http://codeblue.umich.edu/hoomd-blue/citations.html
26 * Any electronic documents citing HOOMD-Blue will link to the HOOMD-Blue website:
27 http://codeblue.umich.edu/hoomd-blue/
29 * Apart from the above required attributions, neither the name of the copyright
30 holder nor the names of HOOMD-blue's contributors may be used to endorse or
31 promote products derived from this software without specific prior written
32 permission.
34 Disclaimer
36 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' AND
37 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR ANY
39 WARRANTIES THAT THIS SOFTWARE IS FREE OF INFRINGEMENT ARE DISCLAIMED.
41 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
42 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
43 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
46 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 /*!
52 \page page_compile_guide_linux_generic Generic Instructions
54 Table of contents:
55 - \ref sec_build_linux_generic_prereq
56 - \ref sec_build_linux_generic_compile
57 - \ref sec_build_linux_generic_mpi
58 <hr>
60 \section sec_build_linux_generic_prereq Software Prerequisites
62 \section software_req_install_linux_python Python
64 First, check if python is already installed
65 ~~~~
66 $ python -V
67 Python 2.7.6
68 ~~~~
69 Make sure that the version is 2.6 or greater. If you get
70 ~~~~
71 bash: python: command not found
72 ~~~~
73 or have a version older than 2.6, you will need to upgrade or install python.
74 You will also need the python development libraries which some distributions might separate into a separate
75 python-devel package. The existence of the python development libraries can be tested
76 by checking the output of
77 ~~~~
78 $ find /usr/include/python* -name Python.h
79 /usr/include/python2.7/Python.h
80 ~~~~
81 The output should be the location of the python development files. If you get
82 ~~~~
83 find: /usr/include/python*: No such file or directory
84 ~~~~
85 or no output, then you do not have the python development libraries installed.
87 On a compute cluster, Python may be installed in a non-standard location and it may be required to set
88 your environment variables to point to these paths. Depending on your cluster configuration, this
89 may be achieved with a command such as
90 ~~~~
91 module load python
92 ~~~~
93 or similar. Please refer to your cluster documentation or contact the administrator for information on how to use
94 software modules.
96 If you don't have Python with development headers installed, you will need to install them.
98 \subsection python-root Installing Python with a package manager
100 If you have administrative privileges on your machine, you may simply use your Linux distribution's package
101 manager to install Python.  The process for installing software differs from linux distribution to
102 distribution.  In Gentoo (http://www.gentoo.org/)
103 ~~~~
104 $ sudo emerge python
105 ~~~~
106 would install python. Look at your linux distribution's documentation to find how to install
107 packages on your system (i.e. yum, apt-get, up2date, or another).
109 \subsection python-source Installing Python from source
111 If you are not the administrator, you can still install python locally.
113 Get the latest python version from http://www.python.org or directly download python 3.3.
114 ~~~~
115 $ wget http://www.python.org/ftp/python/3.3.0/Python-3.3.0.tar.bz2
116 ~~~~
117 Unpack the python archive in a convenient location (you may delete the build directory after installation)
118 ~~~~
119 $ tar -xvfj Python-3.3.0.tar.bz
120 ~~~~
121 and build python
122 ~~~~
123 $ cd Python-3.3.0
124 $ ./configure --enable-shared --prefix=$HOME/local
125 $ make -j 12 install
126 ~~~~
127 This installs python into the `local/` subdirectory of your home directory.
128 The `-j` option tells make to use the CPU cores available in your system for the build process.
130 \section software_req_install_linux_boost Boost
132 First, check if boost is already installed
133 \code
134 $ grep BOOST_LIB_VERSION /usr/include/boost/version.hpp
135 //  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
136 #define BOOST_LIB_VERSION "1_44"
137 \endcode
138 Make sure that the version is 1_39 or newer. If you get
139 \code
140 grep: /usr/include/boost/version.hpp: No such file or directory
141 \endcode
142 then boost is not installed. You can install boost with your distribution's package
143 manager.
145 If your distribution doesn't have a new enough version of boost, or if it is not provided on your cluster,
146 you can build it by hand. Building boost is a time consuming process, but not complicated if you follow these instructions.
148 In order to build boost, you need the development package for bzip. If your
149 distribution provides the pacakge *bzip2-devel*, install it.
150 If not, or if your cluster installation does not have provide the bzip2 header
151 files, you need to install the bzip2 sources.
152 ~~~~
153 $ wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
154 $ tar -xvfz bzip2-1.0.6.tar.bz
155 $ cd bzip2-1.0.6
156 $ make install PREFIX=$HOME/local
157 ~~~~
159 Proceed by downloading `boost_1_52_0.tar.bz2` from http://www.boost.org/. Extract the tarball and
160 configure boost for building with the following commands.
161 ~~~~
162 $ tar -xvjf boost_1_52_0.tar.bz2
163 $ cd boost_1_52_0
164 ~~~~
166 If you have also installed python from source, the Boost installation scripts may not find
167 it automatically. In this case, you need to inform the build system about the location of your python
168 installation.
169 ~~~~
170 $ cp tools/build/v2/user-config.jam $HOME
171 ~~~~
172 Now edit the file `user-config.jam` and add a line
173 ~~~~
174 using python : 3.3 : /home/myuser/local/bin/python3 : /home/myuser/local/include/python3.3m : /home/myuser/local/lib ;
175 ~~~~
176 at the end of file. Now you can build boost.
177 ~~~~
178 $ ./bootstrap.sh --prefix=$HOME/local
179 Building Boost.Build engine with toolset gcc... tools/build/v2/engine/bin.linuxx86_64/b2
180 Detecting Python version... 3.3
182 ~~~~
184 If it reports a different Python version than the one you have requested in
185 your \b user-config.jam file, just ignore that message.
186 The build engine should find the correct Python version nevertheless.
187 Now, run the command
188 ~~~~
189 $ ./b2 install -j 11
190 ~~~~
191 or, if you have installed the bzip2 sources,
192 ~~~~
193 $ ./b2 install -j 10 -s BZIP2_SOURCE=/path/to/bzip2-1.0.6
194 ~~~~
195 and wait some time for everything to compile. At the end, you should see a
196 message saying
197 ~~~~
198 ...updated 963 targets...
199 ~~~~
201 Boost is now installed.
203 You can delete the boost_1_52_0 directory now if you wish. It might be worth
204 saving for a little while until you have compiled HOOMD-blue and know everything
205 is working so that you won't need to go through all the setup steps again.
207 Before running cmake, set the following environment variables to the location where you installed boost:
208 ~~~~
209 $ export BOOST_ROOT=/home/myuser/local
210 $ cmake ../
211 ... continue with build instructions ...
212 ~~~~
214 \section software_req_install_linux_compiler Compiler
216 These instructions test for the installation of gcc. Other C++ compilers can be used
217 if you wish, though compilations with CUDA enabled are only supported with gcc.
219 Test if g++ is installed.
220 ~~~~
221 $ g++ --version
222 $ g++ (GCC) 4.1.2 (Gentoo 4.1.2)
223 ~~~~
224 Any version should do. If you get
225 ~~~~
226 bash: g++: command not found
227 ~~~~
228 then you will need to install gcc using your distributions package management system.
231 \section software_req_install_linux_cmake CMake
233 It is not very likely that your linux distribution includes CMake by default,
234 but check anyways.
235 ~~~~
236  $ cmake --version
237 cmake version 2.8.7
238 ~~~~
239 Make sure the version is 2.6.2 or later. If you have an old version or get
240 ~~~~
241 bash: cmake: command not found
242 ~~~~
243 then you will need to install CMake. Try your distributions package
244 manager first. I.e. in Gentoo
245 ~~~~
246 $ emerge cmake
247 ~~~~
249 If your distribution does not have a cmake package, or you do not have administrator access
250 then you can install it into your home directory by hand. First, download
251 cmake-2.8.12.2-Linux-i386.tar.gz from the Downloads section at http://www.cmake.org.
252 Unpack the tarball to any location you prefer: this example assumes you are installing it to the
253 `${HOME}/local`
254 ~~~~
255 $ mv cmake-2.8.10-Linux-i386.tar.gz ~/local
256 $ cd ~/local
257 $ tar -xvzf cmake-2.8.12.2-Linux-i386.tar.gz
258 ~~~~
259 Then you need to put the bin directory for cmake into your path. If you use bash for a shell you can do
260 this by editing ~/.bashrc. Look for a line with `PATH=...` and add the cmake directory to the end separated
261 by a colon. If you can't find the line, create it like so.
262 ~~~~
263 PATH=$PATH:$HOME/local/cmake-2.8.12.2-Linux-i386/bin
264 export PATH
265 ~~~~
266 Restart your bash shell (or open a new one) and try the version check above to test your installation.
268 \section software_req_install_linux_cuda CUDA
270 CUDA is probably not available by default with your linux distribution. Gentoo offers a package:
271 ~~~~
272 $ emerge nvidia-cuda-toolkit
273 ~~~~
274 but most others do not.
276 If your distribution doesn't come with a package, Follow
277 [NVIDIA's instructions](http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html#package-manager-installation)
278 to install the NVIDIA CUDA repository. Then use your package manager to install cuda. For example:
279 ~~~~
280 sudo yum install cuda
281 ~~~~
283 \section software_req_install_linux_git Git
285 Git is used for version control.
287 First, see if you already have git installed.
288 \code
289  $ git --version
290 git version 1.7.6.1
291 \endcode
292 If you get
293 \code
294 -bash: git: command not found
295 \endcode
296 then you will need to install it with your distribution's package manager.
298 \section sec_build_linux_generic_compile Compile HOOMD-blue
300 Now that all of the prerequisite software is installed, you are ready to compile HOOMD-blue.
302 **Get the source:**
303 There are two ways to get the source code for HOOMD-blue.  You can [download it](http://codeblue.umich.edu/hoomd-blue/download.html)
304 or you can clone the git repository:
305 ~~~~
306 $ git clone https://codeblue.umich.edu/git/hoomd-blue
307 ~~~~
308 By default, the *master* branch will be checked out. This branch includes new features added since the last release.
309 Use `git checkout name` to switch to a different branch or tag.
311 Valid names:
312 - *maint* - includes bugfixes since the last release
313 - *v1.0.0* - Release version 1.0.0
314 - *v0.11.3* - Release version 0.11.3
315 - *etc...*
317 You can verify that a tagged release is exactly as it appeared to the developers when it was created if you
318 have GPG installed.
319 ~~~~
320 $ git cat-file blob 175bf6edfc8ac23c067df1d9bd7b5dd41982be3c | gpg --import
321 $ git tag -v v1.0.0
322 ~~~~
324 **Compile and install HOOMD-blue with makefiles:*
325 ~~~~
326 $ cd hoomd-blue
327 $ mkdir build
328 $ cd build
329 $ cmake ../ -DCMAKE_INSTALL_PREFIX=~/hoomd-install
330 $ make install -j12
331 ~~~~
333 If your build fails because of a version mismatch between the Boost python module and your python
334 installation, you can run cmake with an additional hint to your python installation:
335 ~~~~
336 $ cmake ../code -DPYTHON_EXECUTABLE=$HOME/local/python3.
337 ~~~~
338 and run `make install -j12` again.
340 Now run
341 ~~~~
342 $ make check -j12
343 ~~~~
344 to test your build
346 **Setup your PATH:**
347 Open `~/.bash_profile` and add the following line to the end
348 ~~~~
349 export PATH=$PATH:${HOME}/hoomd-install/bin
350 ~~~~
351 assuming that you set `CMAKE_INSTALL_PREFIX` to `~/hoomd-install` above. If you prefer to install hoomd to a different
352 location, simply set `CMAKE_INSTALL_PREFIX` to the desired directory in the cmake command.
354 Either open a new terminal or
355 ~~~~
356 source ~/.bash_profile
357 ~~~~
358 for the path setting to take effect.
360 <hr>
362 \section sec_build_linux_generic_mpi Compiling with MPI enabled
364 ### Preinstalled MPI
366 If your cluster administrator provides an installation of MPI, you need to figure out if is in your
367 `$PATH`. If the command
368 ~~~~
369 $ which mpicc
370 /usr/bin/mpicc
371 ~~~~
372 succeeds, you're all set. HOOMD-blue should detect your MPI compiler automatically.
374 If this is not the case, set the `MPI_HOME` environment variable to the location of the MPI installation.
375 ~~~~
376 $ echo ${MPI_HOME}
377 /home/software/rhel5/openmpi-1.4.2/gcc
378 ~~~~
380 ### Compile your own MPI: MVAPICH2
382 HOOMD-blue supports the use of CUDA enabled MPI libraries. This offers an extra speed-up
383 of parallel simulations in some cases. This is likely to be true if the GPUs in one node provide
384 peer-to-peer communication capability. To find out if this is the case, run the **simpleP2P** test from
385 the NVIDIA CUDA SDK.
387 If you choose to compile your own MPI, you can run it out of your home directory.
388 MVAPICH2 1.8 (and later) supports CUDA integration that enables fast intra-node GPU performance. The minimum
389 version of MVAPICH2 required for HOOMD is 1.9.
391 ~~~~
392 $ tar -xvzf mvapich2-1.9.tgz
393 $ cd mvapich2-1.9
394 $ ./configure --prefix=${HOME}/local --enable-cuda --with-cuda=${CUDA_ROOT} --enable-shared
395 $ make -j10
396 $ make install
397 ~~~~
399 The following needs to be added to your environment variables in .bash_profile.
400 ~~~~
401 export LD_LIBRARY_PATH=${HOME}/local/lib:${LD_LIBRARY_PATH}    # if not already there
402 export MPI_HOME=${HOME}/local
404 # if using nodes without IB adapters
405 export MV2_USE_SHARED_MEM=1
406 export MV2_SMP_SEND_BUF_SIZE=262144
407 ~~~~
409 ### Compile your own MPI: OpenMPI
411 OpenMPI also supports fast CUDA integration starting with version 1.7.
413 It can be obtained from the [OpenMPI website](http://www.open-mpi.org/).
415 Build OpenMPI with
417 ~~~~
418 $ ./configure --with-cuda=${CUDA_ROOT} --with-cuda-libdir=${CUDA_ROOT}/lib64 --prefix=${HOME}/local --with-hwloc=internal --with-openib=/usr
419  $ make install -j12
420 ~~~~
422 The following needs to be added to your environment variables in .bash_profile.
423 ~~~~
424 export LD_LIBRARY_PATH=${HOME}/local/lib:${LD_LIBRARY_PATH}    # if not already there
425 export MPI_HOME=${HOME}/local
426 ~~~~
427 Then log out and back in before attempting to build boost (so that it can find MPI).
429 ### Build hoomd
431 Configure and build HOOMD-blue as normal (see \ref sec_build_linux_generic_compile). During the cmake step, MPI should
432 be detected and enabled. For cuda-aware MPI, additionally supply the **ENABLE_MPI_CUDA=ON** option to cmake.