In this article, we’ll show you how to install Spack on Ubuntu 20.10/20.04. Spack is a package management tool to install scientific packages and support multiple versions with a wide variety of environments and platforms.
Prerequisites
- Installed Ubuntu 20.10/20.04 server
- root or sudo privileges
Steps to Install Spack on Ubuntu 20.10/20.04
Step 1: Update Ubuntu system
sudo apt-get update -y
Sample Output:
root@Spack:~# sudo apt-get update -y Hit:2 http://us.archive.ubuntu.com/ubuntu groovy InRelease Get:3 http://us.archive.ubuntu.com/ubuntu groovy-updates InRelease [115 kB] Get:4 http://us.archive.ubuntu.com/ubuntu groovy-backports InRelease [101 kB] Get:5 http://us.archive.ubuntu.com/ubuntu groovy-updates/main amd64 Packages [491 kB] Get:6 http://security.ubuntu.com/ubuntu groovy-security InRelease [110 kB] Hit:1 https://downloads.apache.org/cassandra/debian 311x InRelease Get:7 http://us.archive.ubuntu.com/ubuntu groovy-updates/main i386 Packages [216 kB] Get:8 http://us.archive.ubuntu.com/ubuntu groovy-updates/universe amd64 Packages [198 kB] Fetched 1,232 kB in 13s (91.8 kB/s) Reading package lists... Done root@Spack:~#
Step 2: Install Dependencies on Ubuntu
$ sudo apt install build-essential
Step 3: Clone Spack Repository from GitHub Spack Repository
In my case, I am cloning Spack Repository to ~/.spack/Spack.
$ sudo apt install git $ git clone https://github.com/spack/spack ~/.spack/Spack
Sample Output:
root@Spack:~# git clone https://github.com/spack/spack ~/.spack/Spack Cloning into '/root/.spack/Spack'... remote: Enumerating objects: 285291, done. remote: Counting objects: 100% (202/202), done. remote: Compressing objects: 100% (150/150), done. remote: Total 285291 (delta 65), reused 122 (delta 21), pack-reused 285089 Receiving objects: 100% (285291/285291), 115.56 MiB | 236.00 KiB/s, done. Resolving deltas: 100% (121369/121369), done. root@Spack:~#
Step 4: Add Shell
To access/use Spack command from any prompt add it to the PATH.
$ sudo ~/.spack/Spack/share/spack/setup-env.sh
$ echo '. ~/.spack/Spack/share/spack/setup-env.sh' >> ~/.bash_profile $ source ~/.bash_profile
Step 5: Clear Environment
Spack builds and installs packages from their source code, it requires a clean environment. Make sure your PATH only has the things you need.
$ echo $PATH
Sample Output:
root@Spack:~# echo $PATH /root/.spack/Spack/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin root@Spack:~#
Step 6: Verify Spack installation
$ spack -V
Sample Output:
root@Spack:~# spack -V 0.16.2-3080-9da1cb615f
Now, You can install lots of powerful scientific packages via Spack, such as pngwriter.
$ spack install pngwriter $ spack load pngwriter
End of article. We’ve seen How to Install Spack on Ubuntu 20.10/20.04.