Skip to content

Instantly share code, notes, and snippets.

@kentwait
Last active March 27, 2024 14:10
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kentwait/b21b8ede66b9949570a5ab44d957f587 to your computer and use it in GitHub Desktop.
Save kentwait/b21b8ede66b9949570a5ab44d957f587 to your computer and use it in GitHub Desktop.
How to set-up CUDA, BEAGLE, and MrBayes/BEAST

Overview

Bayesian phylogentic programs like MrBayes and BEAST work better when the BEAGLE library is installed. BEAGLE provides these programs with an MCMC sampler using CPU-based or GPU-based computation. Therefore, before compiling or using MrBayes and BEAST, BEAGLE and other prerequisites must be set-up and installed first. Unfortunately, setting-up all these software and libraries can become pretty frustrating very quickly.

Here I show how to properly set-up these programs to keep your frustration to a minimum. Broadly speaking, these instructions are applicable for Windows, Mac, and Linux. However, because I am specifically recounting my own experiencing setting-up my Linux machine, the more detailed parts of this guide focuses on installing on Linux.

Installation

Install CUDA drivers first!

  1. Go to https://developer.nvidia.com/cuda-downloads and fill out the form to download the appropriate CUDA drivers for your OS.
  2. Follow the installation instructions on the download page. In my case, I downloaded CUDA drivers for my Ubuntu 16.04 system. The download page provided me with 4 installer types - runfile (local), deb (local), deb (network), cluster (local). I chose "deb (local)" and downloaded the file (about 2 GB) to my computer.
  3. I installed the CUDA drivers installer following the onscreen instructions on the download page. Below are the instruction I got for installing CUDA in Ubuntu 16.04:
> sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
> sudo apt-get update
> sudo apt-get install cuda

Now you have CUDA drivers installed in your system. Next we need to install the BEAGLE library.

Install BEAGLE library

  1. Go to https://github.com/beagle-dev/beagle-lib and check the README.md on the page for the right installer for your system. Since I am using Ubuntu 16.04, I have to download the source code and compile the library by myself. The following steps are for compiling from source. If you are using Windows or Mac, please download the provided binaries to save yourself the trouble of compiling.
  2. Download the source code by cloning the repository
> git clone --depth=1 https://github.com/beagle-dev/beagle-lib.git
  1. Open the folder you just downloaded by cloning. Create a configuration file by running autogen.sh and configure the installation path. Set the installation path to /usr/local if you have root access or $HOME if not. See the following set of commands below for more detail.
> cd beagle-lib
> ./autogen.sh
> ./configure --prefix=/usr/local
> sudo make install
  1. Add /usr/local to your LD_LIBRARY_PATH and PKG_CONFIG_PATH environment variables. In Ubuntu, open ~/.bashrc and add export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH and export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH to your path. If you do not have root access and installed it somewhere else, please add your installation path to LD_LIBRARY_PATH and PKG_CONFIG_PATH variables instead.
> echo "export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
> echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> ~/.bashrc
  1. Update your system configuration by running source on your updated bash file.
> source ~/.bashrc
  1. Still in the source code folder, run make check to check your installation and if it is communicating properly with your nVidia graphic cards. Everything should pass.

Now you have successfully installed BEAGLE with CUDA support. You can now install software that depend on BEAGLE like MrBayes and BEAST.

Install MrBayes

  1. Download MrBayes from http://mrbayes.sourceforge.net/download.php, selecting the right version for your system. If you are running Windows or Mac, download the compile executable. If like me, you are running Linux, you need to download the source code.
  2. After downloading the source code, extract and go into the folder. Find the src directory and go into that as well. Open the file "CompileInstructions.txt". This document shows the different options available when compiling MrBayes.
> cd mrbayes-3.2.6
> cd src
> nano CompileInstructions.txt
  1. If you have settled on the options to use or are fine with the default, configure MrBayes using .configure and compile using make. If you have root access, install in /usr/local/bin using make install.
> ./configure
> make
> sudo make install

Congratulations! You should now have a working installation of MrBayes with access to the BEAGLE GPU library.

@petRUShka
Copy link

petRUShka commented Jan 8, 2018

Thanks for your guide! Have you seen this git-repository of MrBayes: https://github.com/NBISweden/MrBayes ?

Quotation:

After release 3.2.6 (November 2015), MrBayes entered "maintenance mode",
and its care has been passed over to NBIS (National Bioinformatics
Infrastructure Sweden, http://nbis.se/). The original development
team is still involved with the program, but any future releases will
probably be geared more towards bug-fixes rather than addition of new
features.

Don't you consider to use more maintained version?

@cement-head
Copy link

Thanks so much for this!

@shichaochen
Copy link

Recently, I face the trouble to install beagle library for running beast V1.X. It seems never working properly. Thank you for this instruction document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment