Skip to content

Containers

This page contains instructions and examples for running containers on the CMRI HPC cluster.


Container Support

Containers are supported on the CMRI HPC cluster using the Podman container engine. Podman is a drop-in replacement for Docker; if you are already familiar with Docker, you can use all the same commands!

There are several key differences between running containers in an HPC environment and running them on your own computer:

  1. All containers are rootless. They run under your account, and do not have elevated privileges.
    • You cannot use privileged network ports (<1025).
  2. . Containers are ephemeral. When your job ends, any containers that have not been pushed to a registry will be deleted.
    • Container data is stored locally on each compute node.
  3. The login node (cmri-vm-login) does not support containers. You must use compute nodes for all container operations.
    • Interactive sessions are the recommended way to build containers.

When running a container for the first time on a node, you may see an error like this:

ERRO[0000] cannot find UID/GID for user: No subuid ranges found for user in /etc/subuid - check rootless mode in man pages.

These errors can be safely ignored.

Example Workflows

Given the constraints mentioned above, this section has several example workflows demonstrating how you can run containers on the cluster.

Building and Running

The steps below walk through building and running a container on the CMRI HPC cluster.

  1. Log in to cmri-vm-login and start an interactive session:

    srun --pty /bin/bash
    
  2. In the interactive session, build your container from a Dockerfile:

    docker build -t example .
    
  3. Once the build finishes, run the container:

    docker run example
    

Remember - local container images are deleted when your job ends. You must push your container images to a repository to preserve them.

Example output for these steps is shown below:

[cdietz1@cmri-n10 container-test]$ cat ./Dockerfile
FROM registry.access.redhat.com/ubi8/ubi

RUN dnf install -yq --disableplugin=subscription-manager https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 1>/dev/null
RUN dnf install -yq --disableplugin=subscription-manager --enablerepo epel cowsay 1>/dev/null

CMD cowsay "hello world!"
[cdietz1@cmri-n10 container-test]$ docker build -t example .
STEP 1: FROM registry.access.redhat.com/ubi8/ubi
STEP 2: RUN dnf install -yq --disableplugin=subscription-manager https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 1>/dev/null
--> 08671cc61f9
STEP 3: RUN dnf install -yq --disableplugin=subscription-manager --enablerepo epel cowsay 1>/dev/null
Importing GPG key 0x2F86D6A1:
 Userid     : "Fedora EPEL (8) <epel@fedoraproject.org>"
 Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
--> d5a21d84874
STEP 4: CMD cowsay "hello world!"
STEP 5: COMMIT example
--> 01c65dbce97
01c65dbce97c225942735cd7a8ffeddabf50577b786738885d749cd83b8f5896
[cdietz1@cmri-n10 container-test]$ docker run example
 ______________
< hello world! >
 --------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
[cdietz1@cmri-n10 container-test]$

Using GPUs

The steps below walk through running a GPU enabled container.

  1. Start an interactive session on a GPU node:

srun -p gpu --gpus=1 --pty /bin/bash

  1. Pull a GPU enabled container:

docker pull nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04

  1. Run the container:

docker run cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04

Example output for these steps is shown below:

[cdietz1@cmri-gpu02 ~]$ docker pull nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04
Trying to pull nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04...
Getting image source signatures
Copying blob cde16ef91ac2 done
Copying blob 6c10428f3e1b done
Copying blob 3b65ec22a9e9 done
Copying blob 978ea3dcd5fb done
Copying blob 4f4fb700ef54 done
Copying blob 9bfa49b064c8 done
Copying blob 7c4464641354 done
Copying blob c7917bbfcfe8 done
Copying blob ac5184cb5a69 done
Copying blob acbe074771d6 done
Copying blob 78dc954ca047 done
Copying config c2dcfa922b done
Writing manifest to image destination
Storing signatures
c2dcfa922ba509153ba5d0d7f859853362da9532d82fbd9f2e54c444b47b0a77
[cdietz1@cmri-gpu02 ~]$ docker run cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
[cdietz1@cmri-gpu02 ~]$

Container Notes

This section has recommendations for how to run specific containers on the cluster.

Micapipe

The steps below walk through how to run the Micapipe Docker container on the cluster, including recommended options:

  1. Login to cmri-vm-login with your CMH credentials, then run the screen command.

  2. Start an interactive session with all of the cores and memory available on a compute node using srun:

    srun -c 112 --mem=750G --pty /bin/bash
    
  3. In your interactive session, pull the Micapipe container:

    docker pull micalab/micapipe:v0.2.3
    

    This will take several minutes to finish, the Micapipe container is ~20GB.

  4. Follow steps 1 through 3 in the Micapipe start to finish guide to download and prepare an example dataset, or prepare your own dataset. You may want to consider downloading the data to your /scratch directory depending on the size. See the Data Management page for information on the /scratch filesystem.

  5. Run Micapipe. The first part of the command specifies options for Docker; you can use this example as a starting point and customize the data (/bids) and output (/out) paths:

    docker run -ti --rm \
    -v /path/to/your/data:/bids \
    -v /path/to/write/output:/out \
    -v /software/licenses/freesurfer_license.txt:/opt/freesurfer_license.txt \
    -v /dev/shm:/tmp \
    

    The second part of the command specifies the container to run and passes options to Micapipe. You can copy the first five lines of this example verbatim, but the other lines will change depending on which pipeline stages you want to run:

    micalab/micapipe:v0.2.3 \
    -fs_licence /opt/freesurfer_license.txt \
    -bids /bids \
    -out /out \
    -threads 112 \
    -sub HC001 -ses 01 \
    -proc_structural \
    -proc_surf -freesurfer \
    -post_structural \
    -proc_dwi \
    -SC -tracts 20M \
    -proc_func \
    -GD \
    -MPC -regSynth \
    -QC_subj
    

    All together, this is the command for running Micapipe with the MICs dataset shown in the Micapipe start to finish tutorial:

    docker run -ti --rm -v /path/to/your/data:/bids -v /path/to/write/output:/out -v /software/licenses/freesurfer_license.txt:/opt/freesurfer_license.txt -v /dev/shm:/tmp micalab/micapipe:v0.2.3 -fs_licence /opt/freesurfer_license.txt -bids /bids -out /out -threads 112 -sub HC001 -ses 01 -proc_structural -proc_surf -freesurfer -post_structural -proc_dwi -SC -tracts 20M -proc_func -GD -MPC -regSynth -QC_subj
    
  6. You can disconnect from your screen session by pressing Ctrl + A + D, and wait for the pipeline to finish (run screen -r to reconnect). Once you know how long the pipeline takes to process your dataset, you may want to write a job script to automate these steps.