-
Notifications
You must be signed in to change notification settings - Fork 29
SIRF SuperBuild on Docker
Docker is a low-overhead, container-based replacement for virtual machines (VMs).
This works best on a linux system due to:
- Possibility to get CUDA support within the container
-
X11
windows displayed natively without needing e.g. avnc
server or desktop in the container
This is probably the easiest way to use SIRF
due to really short installation instructions essentially consisting of:
docker-compose up --no-start sirf
docker start -ai sirf
- Docker
- The free Community Edition (CE) is sufficient
docker-compose
- The
SIRF-SuperBuild
repository- download and unzip or
git clone
this locally
- download and unzip or
A wonderfully tiny list of everything important to know for a basic working knowledge of docker.
-
Base image: the starting point for building a Docker image
- analogous to a clean OS (in this case
ubuntu:16.04
)
- analogous to a clean OS (in this case
-
Layer: a single build step
- usually represented by a single line in a
Dockerfile
(e.g.apt-get install cmake
)
- usually represented by a single line in a
-
Image: a sequence of layers (applied on top of a base image)
- analogous to a clean OS with
SIRF
installed (in this case taggedccppetmr/sirf
)
- analogous to a clean OS with
-
Container: a sandboxed workspace derived from an image
- analogous to a running virtual machine (in this case named
sirf
) - easily stoppable, restartable, disposable
- can be thought of as end-user-created layers which would never be formally part of a redistributable image
- can share files, network connections, and devices with the host computer
- analogous to a running virtual machine (in this case named
Images are built or pulled. Containers are created from them:
-
Build: typically refers to pulling a base image, then building all the layers necessary to form an image
- usually once-off
-
Pull: typically refers to downloading an image from the internet (which someone else built)
- usually only required when there is no source code available to allow for building locally
-
Create: typically refers to making a container from an image
- often recreated for a semi-clean slate - especially if data is shared with the host computer so that no data is lost on disposal
The docker image can be built from source using CCPPETMR/SIRF-SuperBuild
by following the steps below. Alternatively, simply run docker pull ccppetmr/sirf
to download a pre-built image.
docker-compose
is used to help with creating containers (and even building images). It should be added to your PATH
or at least have the executable copied to SIRF-SuperBuild/docker
.
For easier file and window sharing, the image ccppetmr/sirf
should be built using the host user's ID and some environment variables:
SIRF-SuperBuild/docker$ docker-compose -f docker-compose.yml \
-f docker-compose.nix.yml build \
--build-arg UID=$(id -u) --build-arg GROUPS=$(id -g) base sirf
After this a container called sirf
is created:
SIRF-SuperBuild/docker$ docker-compose up --no-start sirf
For the first step, instead of passing user IDs, Windows requires that file sharing is enabled. Then:
Either:
SIRF-SuperBuild/docker> docker pull ccppetmr/sirf
Or:
SIRF-SuperBuild/docker> docker-compose build base sirf
Then:
SIRF-SuperBuild/docker> docker-compose up --no-start sirf
You may want to consult SIRF-SuperBuild-on-Bash-on-Ubuntu-on-Windows-10 regarding setting up Xserver/VNCserver and other UNIX-for-Windows-users tips.
ccache
is used in the container to speed up rebuilding images from scratch.
The cache is pulled from the host machine via the devel/.ccache
folder.
To replace the host's cache with the updated one from the container, run:
SIRF-SuperBuild/docker$ sudo rm -rf devel/.ccache/*
SIRF-SuperBuild/docker$ docker-compose run --rm sirf \
/bin/bash -c 'sudo cp -R ccache/* /devel/.ccache/'
Well, that was easy. The container can be run interactively for daily use.
SIRF-SuperBuild/docker$ docker start -ai sirf
(py2) sirf:~$ gadgetron >> /dev/null &
(py2) sirf:~$ python SIRF-SuperBuild/SIRF/examples/Python/MR/fully_sampled_recon.py
The first line starts the sirf
docker container.
The second line starts gadgetron
within the container as a background process.
Finally, we can then run an example.
Note that the devel
folder in the host's SIRF-SuperBuild/docker
directory is mounted to /devel
in the container.
- Tests can be run (after
gadgetron
is started) as follows:
(py2) sirf:~$ cd SIRF-SuperBuild
(py2) sirf:~/SIRF-SuperBuild (master)$ pip install nose
(py2) sirf:~/SIRF-SuperBuild (master)$ ctest -VV
- "Cannot connect to display" errors are usually fixed by running
xhost +local:""
on the host linux system - Non-linux users (e.g. Windows) will need to set up a desktop and vnc server in order to have a GUI (docker files coming soon)
- On host systems with less than 16GB RAM, before
docker-compose up ...
you may want to editSIRF-SuperBuild/docker/user_sirf-ubuntu.sh
, changing the linemake -j...
to simplymake
. This increases build time and reduces build memory requirements.