rgb.sh RSS

Installing MAGMA on Ubuntu 18.04

July 3 2019

A brief walkthrough of getting the GPU-accelerated linear algebra library MAGMA set up.

MAGMA is an awesome library providing GPU-accelerated versions of BLAS and LAPACK functions. I’ve had to install MAGMA a number of times at this point, yet I always manage to mess it up on my first try. Here are all of the steps involved to install MAGMA.

1. Install CUDA

Follow the directions at https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=debnetwork to install the latest version of CUDA (e.g. Network Install of 10.1.168-1):

wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.168-1_amd64.deb

sudo dpkg -i cuda-repo-ubuntu1804_10.1.168-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

Edit your ~/.bash_aliases file according to https://docs.nvidia.com/cuda/cuda-installation-guide-linux/#environment-setup:

export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64\
                       ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

2. Install Other Prerequisites

MAGMA needs a BLAS library as well as a Fortran compiler. OpenBLAS seems to be the fastest based on a quick search of online benchmarks.

sudo apt install libopenblas-dev gfortran

3. Install MAGMA

First, download and extract the latest version (e.g. 2.5.1-alpha1) of the source code from https://icl.utk.edu/magma/software/index.html:

wget http://icl.utk.edu/projectsfiles/magma/downloads/magma-2.5.1-alpha1.tar.gz
tar -xzf magma-2.5.1-alpha1.tar.gz

Update your ~/.bash_aliases according to https://icl.cs.utk.edu/projectsfiles/magma/doxygen/installing.html:

export CUDADIR=/usr/local/cuda
export OPENBLASDIR=/usr/lib/x86_64-linux-gnu/openblas

Build MAGMA and install it. This assumes you want to build the default shared library. See https://icl.cs.utk.edu/projectsfiles/magma/doxygen/installing.html and the included README’s for detailed instructions. The default install directory /usr/local/magma will need temporary write permissions for make install to succeed:

make
sudo mkdir /usr/local/magma
sudo chown $(whoami) /usr/local/magma
make install
sudo chown -R root /usr/local/magma

Finally, add MAGMA to your shared library path by appending to ~/.bash_aliases:

export LD_LIBRARY_PATH=/usr/local/magma/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

You’re now done installing MAGMA!