Skip to content

Commit

Permalink
doc: Add definition files for singularity containers with BART
Browse files Browse the repository at this point in the history
  • Loading branch information
scholand authored and uecker committed Jul 19, 2024
1 parent d1a62a6 commit a660b54
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
33 changes: 33 additions & 0 deletions doc/singularity/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Singularity Container for BART

Running BART on a high performance computing (HPC) cluster can be challenging due to missing libraries.
One solution exploits containers. They encapsulating the software with all required dependencies.
Here, we provide some basic information about how to run BART in a container using [Singularity](https://sylabs.io/singularity/).

A blueprint to create a singularity container for BART can be found in the definition files
* [`bart_ubuntu.def`](bart_ubuntu.def): for an Ubuntu 22.04 operating system.
* [`bart_debian.def`](bart_debian.def): for a Debain 12 (bookworm) operating system.

After installing singularity, a container `container.sif` can be created in the Singularity Image Format (SIF):
```code
sudo singularity build container.sif bart.def
```

Both containers download and compile BART with all libraries including GPU support using CUDA.
Make sure to select the CUDA version your local HPC host provides.

You can start an interactive shell with

```code
singularity shell --nv container.sif
```
and the `--nv` adds access to the installed Nvidia drivers on the host system.

A BASH script can be executed inside the container with

```code
singularity exec --nv container.sif bash 'recon.sh'
```

### Note
The definition files above also respresent simple guides of how to install BART on the individual operating systems.
52 changes: 52 additions & 0 deletions doc/singularity/bart_debian.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Bootstrap: docker
From: debian:12

%labels
Author Nick Scholand
Version debian-v1.0

%help
This is a container running debian bookworm (12) with the Berkeley Advanced Reconstruction Toolbox (BART) and its viewer tool.
It deploys the code of a specified version and compiles it with GPU support using CUDA.
Ensure to select the same CUDA version as installed on your host.
To compile the specified BART version without CUDA support remove `CUDA=1` from the `printf` string below.

%environment
export BART_TOOLBOX_PATH=/bart
export TOOLBOX_PATH=/bart
export LD_LIBRARY_PATH=/bart/lib:$LD_LIBRARY_PATH
export PATH=/bart:$PATH
export PATH=/view:$PATH

%post
# Allow non-free packages
sed -i -e 's/Components: main/Components: main contrib non-free non-free-firmware/g' /etc/apt/sources.list.d/debian.sources
apt-get update

# Install general libraries for BART and BART's viewer tool
apt-get install -y libfftw3-dev liblapacke-dev libpng-dev libopenblas-dev libgtk-3-dev

# Install useful tools for the installation process and workflows
apt-get install -y make gcc git wget vim dpkg unzip screen time bc

# Install CUDA
CUDA_VERSION=12-3
wget https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb
dpkg -i cuda-keyring_1.1-1_all.deb
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y install cuda-${CUDA_VERSION} # `DEBIAN_FRONTEND=noninteractive` avoids keyboard pop-up

# Install BART and compile it with GPU support
BART_VERSION=0.9.00
wget https://github.com/mrirecon/bart/archive/v${BART_VERSION}.zip
unzip v${BART_VERSION}.zip
mv bart-${BART_VERSION} bart
rm v${BART_VERSION}.zip
cd bart
touch Makefiles/Makefile.local
printf "PARALLEL=1\nCUDA=1\nCUDA_BASE=/usr/local/cuda\nCUDA_LIB=lib64\n" > Makefiles/Makefile.local
make
cd ..

# Install BART's viewer tool
apt-get -y install bart-view
50 changes: 50 additions & 0 deletions doc/singularity/bart_ubuntu.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Bootstrap: library
From: ubuntu:22.04

%labels
Author Nick Scholand
Version ubuntu-v1.0

%help
This is a container running Ubuntu 22.04 with the Berkeley Advanced Reconstruction Toolbox (BART) and its viewer tool.
It deploys the code of a specified version and compiles it with GPU support using CUDA.
Ensure to select the same CUDA version as installed on your host.
To compile the specified BART version without CUDA support remove `CUDA=1` from the `printf` string below.

%environment
export BART_TOOLBOX_PATH=/bart
export TOOLBOX_PATH=/bart
export LD_LIBRARY_PATH=/bart/lib:$LD_LIBRARY_PATH
export PATH=/bart:$PATH
export PATH=/view:$PATH

%post
apt-get update

# Install general libraries for BART and BART's viewer tool
apt-get install -y libfftw3-dev liblapacke-dev libpng-dev libopenblas-dev libgtk-3-dev

# Install useful tools for the installation process and workflows
apt-get install -y make gcc git wget vim dpkg unzip screen time bc

# Install CUDA
CUDA_VERSION=12-0
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
dpkg -i cuda-keyring_1.1-1_all.deb
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y install cuda-${CUDA_VERSION} # `DEBIAN_FRONTEND=noninteractive` avoids keyboard pop-up

# Install BART and compile it with GPU support
BART_VERSION=0.9.00
wget https://github.com/mrirecon/bart/archive/v${BART_VERSION}.zip
unzip v${BART_VERSION}.zip
mv bart-${BART_VERSION} bart
rm v${BART_VERSION}.zip
cd bart
touch Makefiles/Makefile.local
printf "PARALLEL=1\nCUDA=1\nCUDA_BASE=/usr/local/cuda\nCUDA_LIB=lib64\n" > Makefiles/Makefile.local
make
cd ..

# Install BART's viewer tool
apt-get -y install bart-view

0 comments on commit a660b54

Please sign in to comment.