Update boost build instructions
[hoomd-blue.git] / doc / user / compile_guide_linux_generic.dox
blob7c18b0fdb00ef4bcc131928e8c9a1641264b37db
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 Proceed by downloading `boost_1_55_0.tar.bz2` from http://www.boost.org/. Extract the tarball and
149 configure boost for building with the following commands.
150 ~~~~
151 $ tar -xvjf boost_1_55_0.tar.bz2
152 $ cd boost_1_55_0
153 ~~~~
155 Next, run the bootstrap.
157 $ ./bootstrap.sh --prefix=$HOME/local
158 Building Boost.Build engine with toolset gcc... tools/build/v2/engine/bin.linuxx86_64/b2
159 Detecting Python version... 2.6  <--- ignore this if you built python from source
162 If you built python from source, edit the file `project-config.jam` and replace the `using python` line with this:
163 ~~~~
164 using python : 3.3 : /home/myuser/local/bin/python3 : /home/myuser/local/include/python3.3m : /home/myuser/local/lib ;
165 ~~~~
167 Now you can build boost. Run:
168 ~~~~
169 $ ./b2 install -j 11
170 ~~~~
171 and wait some time for everything to compile. At the end, you should see a
172 message saying
173 ~~~~
174 ...updated 963 targets...
175 ~~~~
176 If it reports that some targets were skipped, run the build command again to see the compiler errors. Most likely the
177 skipped targets are the python libraries and you can correct the problem by double checking the paths in
178 `project-config.jam`
180 Boost is now installed.
182 You can delete the boost_1_55_0 directory now if you wish. It might be worth
183 saving for a little while until you have compiled HOOMD-blue and know everything
184 is working so that you won't need to go through all the setup steps again.
186 Before running cmake, set the following environment variables to the location where you installed boost:
187 ~~~~
188 $ export BOOST_ROOT=$HOME/local
189 $ cmake ../
190 ... continue with build instructions ...
191 ~~~~
193 \section software_req_install_linux_compiler Compiler
195 These instructions test for the installation of gcc. Other C++ compilers can be used
196 if you wish, though compilations with CUDA enabled are only supported with gcc.
198 Test if g++ is installed.
199 ~~~~
200 $ g++ --version
201 $ g++ (GCC) 4.1.2 (Gentoo 4.1.2)
202 ~~~~
203 Any version should do. If you get
204 ~~~~
205 bash: g++: command not found
206 ~~~~
207 then you will need to install gcc using your distributions package management system.
210 \section software_req_install_linux_cmake CMake
212 It is not very likely that your linux distribution includes CMake by default,
213 but check anyways.
214 ~~~~
215  $ cmake --version
216 cmake version 2.8.7
217 ~~~~
218 Make sure the version is 2.6.2 or later. If you have an old version or get
219 ~~~~
220 bash: cmake: command not found
221 ~~~~
222 then you will need to install CMake. Try your distributions package
223 manager first. I.e. in Gentoo
224 ~~~~
225 $ emerge cmake
226 ~~~~
228 If your distribution does not have a cmake package, or you do not have administrator access
229 then you can install it into your home directory by hand. First, download
230 cmake-2.8.12.2-Linux-i386.tar.gz from the Downloads section at http://www.cmake.org.
231 Unpack the tarball to any location you prefer: this example assumes you are installing it to the
232 `${HOME}/local`
233 ~~~~
234 $ mv cmake-2.8.10-Linux-i386.tar.gz ~/local
235 $ cd ~/local
236 $ tar -xvzf cmake-2.8.12.2-Linux-i386.tar.gz
237 ~~~~
238 Then you need to put the bin directory for cmake into your path. If you use bash for a shell you can do
239 this by editing ~/.bashrc. Look for a line with `PATH=...` and add the cmake directory to the end separated
240 by a colon. If you can't find the line, create it like so.
241 ~~~~
242 PATH=$PATH:$HOME/local/cmake-2.8.12.2-Linux-i386/bin
243 export PATH
244 ~~~~
245 Restart your bash shell (or open a new one) and try the version check above to test your installation.
247 \section software_req_install_linux_cuda CUDA
249 CUDA is probably not available by default with your linux distribution. Gentoo offers a package:
250 ~~~~
251 $ emerge nvidia-cuda-toolkit
252 ~~~~
253 but most others do not.
255 If your distribution doesn't come with a package, Follow
256 [NVIDIA's instructions](http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html#package-manager-installation)
257 to install the NVIDIA CUDA repository. Then use your package manager to install cuda. For example:
258 ~~~~
259 sudo yum install cuda
260 ~~~~
262 \section software_req_install_linux_git Git
264 Git is used for version control.
266 First, see if you already have git installed.
267 \code
268  $ git --version
269 git version 1.7.6.1
270 \endcode
271 If you get
272 \code
273 -bash: git: command not found
274 \endcode
275 then you will need to install it with your distribution's package manager.
277 \section sec_build_linux_generic_compile Compile HOOMD-blue
279 Now that all of the prerequisite software is installed, you are ready to compile HOOMD-blue.
281 **Get the source:**
282 There are two ways to get the source code for HOOMD-blue.  You can [download it](http://codeblue.umich.edu/hoomd-blue/download.html)
283 or you can clone the git repository:
284 ~~~~
285 $ git clone https://codeblue.umich.edu/git/hoomd-blue
286 ~~~~
287 By default, the *master* branch will be checked out. This branch includes new features added since the last release.
288 Use `git checkout name` to switch to a different branch or tag.
290 Valid names:
291 - *maint* - includes bugfixes since the last release
292 - *v1.0.0* - Release version 1.0.0
293 - *v0.11.3* - Release version 0.11.3
294 - *etc...*
296 You can verify that a tagged release is exactly as it appeared to the developers when it was created if you
297 have GPG installed.
298 ~~~~
299 $ git cat-file blob 175bf6edfc8ac23c067df1d9bd7b5dd41982be3c | gpg --import
300 $ git tag -v v1.0.0
301 ~~~~
303 **Compile and install HOOMD-blue with makefiles:*
304 ~~~~
305 $ cd hoomd-blue
306 $ mkdir build
307 $ cd build
308 $ cmake ../ -DCMAKE_INSTALL_PREFIX=~/hoomd-install
309 $ make install -j12
310 ~~~~
312 If your build fails because of a version mismatch between the Boost python module and your python
313 installation, you can run cmake with an additional hint to your python installation:
314 ~~~~
315 $ cmake ../code -DPYTHON_EXECUTABLE=$HOME/local/python3.
316 ~~~~
317 and run `make install -j12` again.
319 Now run
320 ~~~~
321 $ make check -j12
322 ~~~~
323 to test your build
325 **Setup your PATH:**
326 Open `~/.bash_profile` and add the following line to the end
327 ~~~~
328 export PATH=$PATH:${HOME}/hoomd-install/bin
329 ~~~~
330 assuming that you set `CMAKE_INSTALL_PREFIX` to `~/hoomd-install` above. If you prefer to install hoomd to a different
331 location, simply set `CMAKE_INSTALL_PREFIX` to the desired directory in the cmake command.
333 Either open a new terminal or
334 ~~~~
335 source ~/.bash_profile
336 ~~~~
337 for the path setting to take effect.
339 <hr>
341 \section sec_build_linux_generic_mpi Compiling with MPI enabled
343 ### Preinstalled MPI
345 If your cluster administrator provides an installation of MPI, you need to figure out if is in your
346 `$PATH`. If the command
347 ~~~~
348 $ which mpicc
349 /usr/bin/mpicc
350 ~~~~
351 succeeds, you're all set. HOOMD-blue should detect your MPI compiler automatically.
353 If this is not the case, set the `MPI_HOME` environment variable to the location of the MPI installation.
354 ~~~~
355 $ echo ${MPI_HOME}
356 /home/software/rhel5/openmpi-1.4.2/gcc
357 ~~~~
359 ### Compile your own MPI: MVAPICH2
361 HOOMD-blue supports the use of CUDA enabled MPI libraries. This offers an extra speed-up
362 of parallel simulations in some cases. This is likely to be true if the GPUs in one node provide
363 peer-to-peer communication capability. To find out if this is the case, run the **simpleP2P** test from
364 the NVIDIA CUDA SDK.
366 If you choose to compile your own MPI, you can run it out of your home directory.
367 MVAPICH2 1.8 (and later) supports CUDA integration that enables fast intra-node GPU performance. The minimum
368 version of MVAPICH2 required for HOOMD is 1.9.
370 ~~~~
371 $ tar -xvzf mvapich2-1.9.tgz
372 $ cd mvapich2-1.9
373 $ ./configure --prefix=${HOME}/local --enable-cuda --with-cuda=${CUDA_ROOT} --enable-shared
374 $ make -j10
375 $ make install
376 ~~~~
378 The following needs to be added to your environment variables in .bash_profile.
379 ~~~~
380 export LD_LIBRARY_PATH=${HOME}/local/lib:${LD_LIBRARY_PATH}    # if not already there
381 export MPI_HOME=${HOME}/local
383 # if using nodes without IB adapters
384 export MV2_USE_SHARED_MEM=1
385 export MV2_SMP_SEND_BUF_SIZE=262144
386 ~~~~
388 ### Compile your own MPI: OpenMPI
390 OpenMPI also supports fast CUDA integration starting with version 1.7.
392 It can be obtained from the [OpenMPI website](http://www.open-mpi.org/).
394 Build OpenMPI with
396 ~~~~
397 $ ./configure --with-cuda=${CUDA_ROOT} --with-cuda-libdir=${CUDA_ROOT}/lib64 --prefix=${HOME}/local --with-hwloc=internal --with-openib=/usr
398  $ make install -j12
399 ~~~~
401 The following needs to be added to your environment variables in .bash_profile.
402 ~~~~
403 export LD_LIBRARY_PATH=${HOME}/local/lib:${LD_LIBRARY_PATH}    # if not already there
404 export MPI_HOME=${HOME}/local
405 ~~~~
406 Then log out and back in before attempting to build boost (so that it can find MPI).
408 ### Build hoomd
410 Configure and build HOOMD-blue as normal (see \ref sec_build_linux_generic_compile). During the cmake step, MPI should
411 be detected and enabled. For cuda-aware MPI, additionally supply the **ENABLE_MPI_CUDA=ON** option to cmake.