To build the HOOMD-blue Python package from source:
-
$ <package-manager> install cmake eigen git python numpy pybind11
-
$ git clone --recursive https://github.com/glotzerlab/hoomd-blue
-
$ cmake -B build/hoomd -S hoomd-blue
-
$ cmake --build build/hoomd
Install the package (optional):
$ cmake --install build/hoomd
To build the documentation from source (optional):
-
$ <package-manager> install sphinx sphinx_rtd_theme nbsphinx ipython
-
$ sphinx-build -b html hoomd-blue/sphinx-doc build/hoomd-documentation
The sections below provide details on each of these steps.
HOOMD-blue requires a number of tools and libraries to build. The options ENABLE_MPI,
ENABLE_GPU, ENABLE_TBB, and BUILD_JIT each require additional libraries when enabled.
Note
This documentation is generic. Replace <package-manager> with your package or module
manager. You may need to adjust package names and/or install additional packages, such as
-dev packages that provide headers needed to build hoomd.
Tip
Create a virtual environment, one place where you can install dependencies and HOOMD-blue:
$ python3 -m venv hoomd-venv
You will need to activate your environment before configuring HOOMD-blue:
$ source hoomd-venv/bin/activate
Note
Some package managers (such as pip) and many clusters are missing some or all of pybind11,
eigen, and cereal. install-prereq-headers.py will install these packages into your
virtual environment:
$ python3 hoomd-blue/install-prereq-headers.py
General requirements:
- C++14 capable compiler (tested with
gcc7, 8, 9, 10, 11 /clang6, 7, 8, 9, 10, 11) - Python >= 3.6
- NumPy >= 1.7
- pybind11 >= 2.2
- Eigen >= 3.2
- CMake >= 3.9
For MPI parallel execution (required when ENABLE_MPI=on):
- MPI (tested with OpenMPI, MVAPICH)
- cereal >= 1.1
For GPU execution (required when ENABLE_GPU=on):
NVIDIA CUDA Toolkit >= 9.0
OR
AMD ROCm >= 3.5.0 with additional dependencies:
- HIP [with
hipccandhccas backend] - rocFFT
- rocPRIM
- rocThrust
- hipCUB, included for NVIDIA GPU targets, but required as an external dependency when building for AMD GPUs
- roctracer-dev
- Linux kernel >= 3.5.0
For HOOMD-blue on AMD GPUs, the following limitations currently apply.
- Certain kernels trigger an unknown HSA error.
- The mpcd component is disabled on AMD GPUs.
- Multi-GPU execution via unified memory is not available.
- HIP [with
For threaded parallelism on the CPU (required when ENABLE_TBB=on):
- Intel Threading Building Blocks >= 4.3
For runtime code generation (required when BUILD_JIT=on):
- LLVM >= 6.0
To build the documentation:
- sphinx
- sphinx_rtd_theme
- nbsphinx
- ipython
Clone using Git:
$ git clone --recursive https://github.com/glotzerlab/hoomd-blue
Release tarballs are also available on the downloads page.
.. seealso::
See the `git book`_ to learn how to work with Git repositories.
Warning
HOOMD-blue uses Git submodules. Clone with the --recursive to clone the submodules.
Execute git submodule update --init to fetch the submodules each time you switch branches
and the submodules show as modified.
Use CMake to configure a HOOMD-blue build in the given directory. Pass
-D<option-name>=<value> to cmake to set options on the command line. When modifying code,
you only need to repeat the build step to update your build - it will automatically reconfigure
as needed.
Tip
Use Ninja to perform incremental builds in less time:
$ cmake -B build/hoomd -S hoomd-blue -GNinja
Tip
Place your build directory in /tmp or /scratch for faster builds. CMake performs
out-of-source builds, so the build directory can be anywhere on the filesystem.
Tip
Pass the following options to cmake to optimize the build for your processor:
-DCMAKE_CXX_FLAGS=-march=native -DCMAKE_C_FLAGS=-march=native.
Important
When using a virtual environment, activate the environment and set the cmake prefix path
before running CMake: $ export CMAKE_PREFIX_PATH=<path-to-environment>.
HOOMD-blue's cmake configuration accepts a number of options.
Options that find libraries and executables only take effect on a clean invocation of CMake. To set
these options, first remove CMakeCache.txt from the build directory and then run cmake with
these options on the command line.
PYTHON_EXECUTABLE- Specify whichpythonto build against. Example:/usr/bin/python3.- Default:
python3.Xdetected on$PATH.
- Default:
CMAKE_CUDA_COMPILER- Specify whichnvccorhipccto build with.- Default: location of
nvccdetected on$PATH.
- Default: location of
MPI_HOME(env var) - Specify the location where MPI is installed.- Default: location of
mpiccdetected on the$PATH.
- Default: location of
<package-name>_ROOT- Specify the location of a package.- Default: Found on the CMake search path.
Other option changes take effect at any time:
BUILD_HPMC- When enabled, build thehoomd.hpmcmodule (default:on).BUILD_MD- When enabled, build thehoomd.mdmodule (default:on).BUILD_METAL- When enabled, build thehoomd.metalmodule (default:on).BUILD_TESTING- When enabled, build unit tests (default:on).CMAKE_BUILD_TYPE- Sets the build type (case sensitive) Options:Debug- Compiles debug information into the library and executables. Enables asserts to check for programming mistakes. HOOMD-blue will run slow when compiled inDebugmode, but problems are easier to identify.RelWithDebInfo- Compiles with optimizations and debug symbols.Release- (default) All compiler optimizations are enabled and asserts are removed. Recommended for production builds.
CMAKE_INSTALL_PREFIX- Directory to install HOOMD-blue. Defaults to the root path of the found Python executable.ENABLE_GPU- When enabled, compiled GPU accelerated computations (default:off).SINGLE_PRECISION- Controls precision (default:off).- When set to
on, all calculations are performed in single precision. - When set to
off, all calculations are performed in double precision.
- When set to
ENABLE_HPMC_MIXED_PRECISION- Controls mixed precision in thehpmccomponent. When on, single precision is forced in expensive shape overlap checks.ENABLE_MPI- Enable multi-processor/GPU simulations using MPI.- When set to
on, multi-processor/multi-GPU simulations are supported. - When set to
off(the default), always run in single-processor/single-GPU mode.
- When set to
ENABLE_MPI_CUDA- Enable CUDA-aware MPI library support.- Requires a MPI library with CUDA support to be installed.
- When set to
on, HOOMD-blue will make use of the capability of the MPI library to accelerate CUDA-buffer transfers. - When set to
off, standard MPI calls will be used.
ENABLE_TBB- Enable support for Intel's Threading Building Blocks (TBB).- When set to
on, HOOMD-blue will use TBB to speed up calculations in some classes on multiple CPU cores.
- When set to
PYTHON_SITE_INSTALL_DIR- Directory to installhoomdto relative toCMAKE_INSTALL_PREFIX. Defaults to thesite-packagesdirectory used by the found Python executable.
These options control CUDA compilation via nvcc:
CUDA_ARCH_LIST- A semicolon-separated list of GPU architectures to compile.
The command cmake --build build/hoomd will build the HOOMD-blue Python package in the given
build directory. After the build completes, the build directory will contain a functioning Python
package.
The command cmake --install build/hoomd installs the given HOOMD-blue build to
${CMAKE_INSTALL_PREFIX}/${PYTHON_SITE_INSTALL_DIR}. CMake autodetects these paths, but you can
set them manually in CMake.
Run Sphinx to build the documentation with the command
sphinx-build -b html hoomd-blue/sphinx-doc build/hoomd-documentation. Open the file
:file:`build/hoomd-documentation/index.html` in your web browser to view the documentation.
Tip
When iteratively modifying the documentation, the sphinx options -a -n -W -T --keep-going
are helpful to produce docs with consistent links in the side panel and to see more useful error
messages:
$ sphinx-build -a -n -W -T --keep-going -b html \
hoomd-blue/sphinx-doc build/hoomd-documentation