Just wanted to share my notes on steps I have taken to get the workshop image to kind of work on the CBU Singularity cluster. I don't know how popular Singularity is at other HPCs (now that there's Podman for user-level container running I don't really see the point of Singularity personally), but if there's demand maybe it would be good to support it?
TLDR: for this to work fully we probably need the workshop materials to live in a folder where everyone has rw, since Singularity ignores the specified neuro user in the Dockerfile and runs the container as a new user (with the same user name as in the calling HPC server).
- Pull docker image with
singularity pull docker://miykael/workshop_pybrain. At most HPCs you will have to ask IT to do this for you.
- Create a script called
notebook.sh and place it in a scripts subfolder (here I've used the same dir where I pulled the image. This script will run inside the container, and takes care of getting conda installed and the notebook server started up. The script can look a little like this
#!/bin/bash
# singularity exec script for Michael Notter's pybrain workshop
source /opt/miniconda-latest/etc/profile.d/conda.sh
conda activate neuro
jupyter notebook --no-browser --ip='*' --notebook-dir=/home/neuro/
- Now to run you might put the following in another script
workshop.sh that executes natively. This way users can just run ./workshop.sh to get their notebook up and running with bind mounts to /output and all. Note that the paths below are specific to the CBU imaging system:
outdir=/imaging/"$USER"/pybrain_output
mkdir -p $outdir
singularity exec -C \
--bind /imaging/local/software/singularity_images/pybrain_workshop/scripts:/scripts \
--bind $outdir:/output:rw \
/imaging/local/software/singularity_images/pybrain_workshop/workshop_pybrain.simg \
bash /scripts/notebook.sh
Notice a few adaptations to local conditions: we don't use the standard 'pybrain' password because IT would have our heads, we set --ip='*' so that users can start notebook servers on the HPC and access them in their native computer web browsers (everything is behind a VPN so this is not as terrible for security as you might think), and we don't pin the port since we will have multiple users on the same server.
The main outstanding issue is caused by Singularity's strange practice of running the container as the current user on the calling HPC server, which means that the /home/neuro folders where everything is stored are read-only access. So it's not possible to save notebooks, and this also seems to break test_notebooks.py, since pytest can't create caches: PytestCacheWarning: could notcreate cache path /home/neuro/workshop/.pytest_cache/v/cache/lastfailed. I think it also breaks nipype fairly completely.
For singularity to work it would be better if the workshop contents live in a new root folder /workshop, to which all users have read/write access.
Just wanted to share my notes on steps I have taken to get the workshop image to kind of work on the CBU Singularity cluster. I don't know how popular Singularity is at other HPCs (now that there's Podman for user-level container running I don't really see the point of Singularity personally), but if there's demand maybe it would be good to support it?
TLDR: for this to work fully we probably need the workshop materials to live in a folder where everyone has rw, since Singularity ignores the specified
neurouser in the Dockerfile and runs the container as a new user (with the same user name as in the calling HPC server).singularity pull docker://miykael/workshop_pybrain. At most HPCs you will have to ask IT to do this for you.notebook.shand place it in ascriptssubfolder (here I've used the same dir where I pulled the image. This script will run inside the container, and takes care of getting conda installed and the notebook server started up. The script can look a little like thisworkshop.shthat executes natively. This way users can just run ./workshop.sh to get their notebook up and running with bind mounts to /output and all. Note that the paths below are specific to the CBU imaging system:Notice a few adaptations to local conditions: we don't use the standard 'pybrain' password because IT would have our heads, we set
--ip='*'so that users can start notebook servers on the HPC and access them in their native computer web browsers (everything is behind a VPN so this is not as terrible for security as you might think), and we don't pin the port since we will have multiple users on the same server.The main outstanding issue is caused by Singularity's strange practice of running the container as the current user on the calling HPC server, which means that the
/home/neurofolders where everything is stored are read-only access. So it's not possible to save notebooks, and this also seems to breaktest_notebooks.py, since pytest can't create caches:PytestCacheWarning: could notcreate cache path /home/neuro/workshop/.pytest_cache/v/cache/lastfailed. I think it also breaks nipype fairly completely.For singularity to work it would be better if the workshop contents live in a new root folder
/workshop, to which all users have read/write access.