User Tools

Site Tools


installation:install_hoomd_blue

Install HOOMD-Blue

If you only want to run it and not modify it in any way:

conda install -c conda-forge hoomd # latest cpu/gpu version - should autodetect
conda install -c conda-forge/label/cf201901 hoomd # install 2.9 

The official instructions are here: https://hoomd-blue.readthedocs.io/en/stable/installation.html#compiling-from-source and you should always check them first, read everything before you start executing commands. Then, go through the instructions from top to bottom. Because it works on all systems including clusters, and works with plugins, compiling from source is preferred by far.

All installations follow the same basic steps:

  • install prerequisites (depends on operating system)
  • download source code (using git from https://github.com/glotzerlab/hoomd-blue)
  • compile source code ( cmake and make)
  • install source code (using make, into a directory in the users home, commonly ~/programs or similar)

Installation on different systems

Install hoomd-blue 4 on Mac

These installation instructions are for installing a cpu only version of hoomd-blue 4 on a Mac with Anaconda installed. We first create and enter a virtual environment in Anaconda then install the prerequisites using pip and homebrew. This is only done the first time hoomd-blue is installed. Replace “myenv” with the name of your virtual environment that you would like to place hoomd-blue inside of.

conda create --name myenv
conda activate myenv
pip install numpy
brew install git
brew install cmake
brew install gcc # if clang doesn't work.

The next step is to locate the path to the virtual environment. This can be done using the following command.

conda info --envs

This should display a list of the virtual environments on the computer with the paths to each. Copy the path to the hoomd-blue environment, and replace “<path-to-environment>” in the following command with the environment path from the previous step. Leave the quotation marks in the command.

export CMAKE_PREFIX_PATH="<path-to-environment>"

Now we use git to download hoomd-blue. We are going to install hoomd into a programs folder. In this example, the programs folder is inside of home folder on a Mac. To get to the home folder, create and enter a folder called “programs”, and download hoomd, use these commands:

cd
mkdir programs
cd programs
git clone --recursive https://github.com/glotzerlab/hoomd-blue

We are then going to enter the folder created from downloading hoomd-blue, it is called “hoomd-blue”, then create and enter a directory called “build”.

cd hoomd-blue
mkdir build
cd build

Next we actually compile and build the system. Replace the “4.0.0” with whatever the latest and stable version of hoomd is.

cmake ../ -DCMAKE_INSTALL_PREFIX="../../hoomd-4.0.0"
cmake --build hoomd
cmake --install hoomd

If you run into weird errors with the first cmake step, sometimes old installations can get in the way of building the new version. The following command will remove the contents of the build folder if ran while inside of the build folder.

rm -rf *

Install hoomd-blue 2 on Mac

On mac, we typically want to install a cpu only version without MPI. You usually don't run any simulations on your local workstation/laptop other than testing and developing. We use pip and homebrew to install prerequisites, only for first time:

pip install numpy
brew install git
brew install cmake
brew install gcc # if clang doesn't work

Now we download hoomd-blue:

cd ~/programs
git clone --recursive https://github.com/glotzerlab/hoomd-blue
cd hoomd-blue
# get the source code for a specific tagged version of hoomd
git checkout v2.6.0
mkdir build
cd build
cmake ../ -DCMAKE_INSTALL_PREFIX="../../hoomd-2.6.0/" -DENABLE_CUDA=OFF -DSINGLE_PRECISION=OFF  -DBUILD_TESTING=ON -DENABLE_MPI=OFF -DBUILD_CGCMM=OFF -DBUILD_DEPRECATED=OFF -DENABLE_HPMC_MIXED_PRECISION=OFF -DBUILD_METAL=OFF -DBUILD_HPMC=OFF -DENABLE_MPI_CUDA=OFF

If odd errors appear, use:

rm -rf*

in build folder.Sometimes, old files from previous attempts to install hoomd might block our installation. This command allows to remove all these files of build folder without losing them.

Make sure hoomd version and Python version are compatible.

The flags are mostly disabling some components of hoomd (BUILD_…). If no cuda/mpi is found, it should automatically set those flags (DENABLE_CUDA and DENABLE_MPI) to off. For more flags see https://hoomd-blue.readthedocs.io/en/stable/installation.html#compiling-from-source.

make -j4
make test
make install

If you updated your macOS recently, you might need/want to reinstall your DeveloperTools: (compilers, libraries etc)

sudo rm -rf `xcode-select -p` && xcode-select --install

Install hoomd-blue on Ubuntu

Prerequisites:

  • git
  • cmake
  • python3 + packages
  • (optional) nvidia graphics card drivers + cuda
sudo apt-get install git cmake python3-numpy python3-scipy python3-distutils python3-dev

Now git can be used to download hoomd-blue:

cd ~/programs
git clone --recursive https://github.com/glotzerlab/hoomd-blue.git
cd hoomd-blue
git checkout v2.6.0
mkdir build 
cd build

Configure the compilation with cmake. Carefully check that it does find the right python, if not use the flag PYTHON_EXECUTABLE=<path-to-pytho3-executable> and PYTHON_LIBRARY=<path-to-pytho3-lib> to set the path, Then compile with make:

cmake ../ -DCMAKE_INSTALL_PREFIX="../../hoomd-2.6.0" -DENABLE_CUDA=OFF -DSINGLE_PRECISION=OFF\
 -DBUILD_TESTING=ON -DENABLE_MPI=OFF\
 -DBUILD_CGCMM=OFF -DBUILD_DEPRECATED=OFF -DENABLE_HPMC_MIXED_PRECISION=OFF \
 -DBUILD_METAL=OFF -DBUILD_HPMC=OFF -DENABLE_MPI_CUDA=OFF

if there is a cuda/mpi installation, it should automatically detect it. For more flags see https://hoomd-blue.readthedocs.io/en/stable/installation.html#compiling-from-source.

Note: cuda 10.1 is not compatible with gnu compilers newer than 8.0, so specifying the gcc compiler explicitly might be necessary by adding these flags to the cmake command:

-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8

Now, compile, test and install with make:

make -j4
make test
make install

If “make install” fails at the end, use “sudo make install” to give the command permission to create new files

Install hoomd-blue on Campus Cluster

First, load some useful modules (check periodically for newest versions with module avail):

module load git
module load vim
module load cmake

If you end up using the same modules over and over again, you can put those into your ~/.bashrc

Now, we are using pip to install some of the prerequisites because then we can also install all sorts of python packages later on and use them and hoomd-blue in the same script executed by the python3 executable.

pip install numpy scipy gsd 

Now we download and install hoomd-blue:

cd programs/
git clone --recursive https://github.com/glotzerlab/hoomd-blue
cd hoomd-blue
git checkout v2.9.7  # adjust version number as needed
mkdir build && cd build

Now we load modules we need for compiling hoomd-blue, again, check periodically for the newest versions (But ask about compatibility if using an older hoomd version):

module load cuda/10.0
module load intel/18.0

We use cmake to generate the make files we'll need:

cmake .. -DCMAKE_INSTALL_PREFIX='../../hoomd-2.9.7' -DENABLE_CUDA=ON -DENABLE_MPI=ON \
 -DBUILD_TESTING=OFF -DBUILD_METAL=OFF -DBUILD_HPMC=OFF -DBUILD_DEPRECATED=OFF  \
-DBUILD_CGCMM=OFF  -DSINGLE_PRECISION=OFF

Check that everything looks alright. This includes:

  • No error messages because of missing prerequisites
  • Found the correct python executable and library locations (should be the anaconda one)
  • found cuda

If everything went well, we can actually compile the code

make -j4

This may take a while.

Do not use more than 4 cores ( -j4 ) because it will autokill your job on the login node if you do. We also should not perform tests on the headnode. If needed, a test should be run as submitted job.

Now, the final step is to install (e.g. copy into the specified location) the compiled code:

make install

Done! go test it by submitting a simple test job onto the test queue. You might want to consider adding the installation path to your ~/.bashrc or use sys.path in each script.

Install hoomd-blue 2.9.x on Campus Cluster using conda

Note: The Conda version only works on CPU! The modules you need to load to install succesfully hoomd-2.9.x version on the campuscluster using conda and python 3.8 are:

module load cuda/10.0
module load intel/18.0
module load gcc/7.2.0
module load cmake/3.18.4

Then you clone the git folder of hoomd and follow a similar procedure as the one above:

cd programs/
git clone --recursive https://github.com/glotzerlab/hoomd-blue
cd hoomd-blue
git checkout v2.x.x  # adjust version number as needed
mkdir build && cd build

We use cmake to generate the make files we'll need:

cmake .. -DCMAKE_INSTALL_PREFIX='../../hoomd-2.8.1' -DENABLE_CUDA=ON -DENABLE_MPI=OFF
-DCMAKE_CXX_FLAGS=-march=native -DCMAKE_C_FLAGS=-march=native
 
make -j4

You can test your installation by typing:

ctest

It would be useful to run the test using a bash script and submit it to one of the available GPU nodes on the campuscluster. If no errors occur:

make install

Install hoomd-blue 3.7 on Campus Cluster

This process assumes your personal anaconda environment has been created and activated. If it hasn't, refer to the wiki campus cluster page.

First, load the required modules and install required files. Check for and use the most recent versions using module avail

module load gcc
module load cuda/10.0
module load cmake/3.18.4
module load anaconda/2022-May/3

Then, use conda to install the python packages required by HOOMD-blue

conda install eigen git python numpy pybind11
conda install -c conda-forge cereal

In the event that the conda install of eigen fails, use the following code snippet to install eigen from gitlab.

cd ~/scratch
mkdir programs
cd programs
wget https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.bz2
tar -xvf eigen-3.3.9.tar.bz2
cd eigen-3.3.9
mkdir build
cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=../../eigen-3.3.9_compiled/
make install

Once the necessary packages are installed, we can follow steps similar to those described on the HOOMD-blue documentation. Here, we will be installing HOOMD-Blue 3.7, as v3.8.0 appears to have installation issues at the time of writing.

git clone --recursive https://github.com/glotzerlab/hoomd-blue
cd hoomd-blue
git checkout v3.7.0
git submodule update --init
mkdir build
cd build
cmake .. -DENABLE_GPU=ON -DCMAKE_INSTALL_PREFIX=../../hoomd-blue-3-DHOOMD_GPU_PLATFORM=CUDA-DBUILD_HPMC=OFF -DBUILD_METAL=OFF
make install -j4

Install hoomd-blue on Delta Cluster

First, load some useful modules (check periodically for newest versions with module avail):

module load cmake/3.23.1 
module load anaconda3_gpu/4.13.0 
module load cudnn 
module avail

Download git repository, checkout desired version, make a 'build' folder like described above.

Python path

Add this line to the ~/.bash_profile (on some systems also called ~/.profile or ~/.bashrc or ~/.zprofile) if hoomd-blue should be found by python without specifying sys.path in scripts:

export PYTHONPATH=~/programs/hoomd-2.6.0/:$PYTHONPATH

If you have multiple versions of hoomd and you are changing back and forth, it might be more convenient and more obvious if you specify the sys.path at the top of each script explicitly:

import sys
sys.path.insert(0,"/data/programs/hoomd-2.8.0/")
import hoomd

You can check which version of python is installed with the command:

python --version

Debugging when things go wrong

The cmake step is misbehaving

There are many things that might be going wrong here, so it is hard to give general advice. First, if you have been trying for a while and you are very unsure, it can be helpful to start from a clean slate: remove everything and start from scratch. For this, delete everything in the build folder: rm -rf * in hoomd-blue/build. Also check that you haven't modified the source code or anything like this: git status. This will also confirm the version you are currently trying to install. Then, re-execute cmake ... Carefully read the error message. Usually it is complaining about unmet prerequisites you need to install or things it did not find. Have a look, try to install missing things, or adjust the flags to make it find the right thing. Often this is related to the cmake flags:

  • PYTHON_EXECUTABLE
  • ENABLE_CUDA
  • ENABLE_MPI

Warning: Hoomd-3 has changed most cmake flags.

Hoomd installs, but Python can't find it

If you seemingly have a working hoomd installation, but python says: module hoomd not found or similar import errors. First, let's gather some information:

  • git status somewhere in the hoomd folder will tell you what version of hoomd you have. You can change it with git checkout v2.6.0 etc. Note the version number.
  • ccmake . in the hoomd/build folder shows you all the flags/configuration used for cmake. Note the folder hoomd is or will be installed in (CMAKE_INSTALL_PREFIX). If you hit t, you will toggle the extended view on, where you can scroll down (down arrow key) to also see the python executable (PYTHON_EXECUTABLE), for example /usr/bin/python3 or /usr/local/bin/python3. Hit q to exit. You can also modify any settings here and re-run make.

Now you should know:

  • which version of hoomd (v.2.6.0)
  • where it is installed (CMAKE_INSTALL_PREFIX)
  • and what python it uses (PYTHON_EXECUTABLE)

Now, we can try to figure out what is happening. First, we need to make sure that we are using the same python version as the one hoomd installed with, and if hoomd works when we do use the same version. For this, execute this script with the correct python (PYTHON_EXECUTABLE):

import sys
sys.path.insert(0,"/data/programs/hoomd-2.6.0/"). # Copy the CMAKE_INSTALL_PREFIX here
import hoomd

If this is working, you should have a successful installation. Adding the (CMAKE_INSTALL_PREFIX) to the pythonpath as described above should now work, eliminating the need for sys.path.insert.

Hoomd installs, Tests fail

If the make test step fails, you can execute

ctest --rerun-failed --output-on-failure

to get more details on the failed tests. The command

ctest --verbose 

will execute all tests and give lot's of output, probably too much to parse. If you have specific tests you want to know more about or you are debugging, you can execute only them with

ctest -R <test-name> --verbose
installation/install_hoomd_blue.txt · Last modified: 2024/01/31 21:27 by bj21

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki