Skip to content

Commit 75ab230

Browse files
committed
[UPDATE] detailed instruction to run mousechd with containers
1 parent 2ac0fa7 commit 75ab230

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

README.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,9 @@ In case you run the package on HPC on which you don't have superuser permission,
4040

4141
* Download container to your computer or HPC:
4242
```bash
43-
wget https://zenodo.org/records/13850904/files/mousechd.sif
44-
```
45-
* Download models in advance (only on HPC), copy and paste in command line on HPC:
46-
```
47-
ver=13785314
48-
mkdir -p ~/.MouseCHD/Classifier/"$ver" && cd ~/.MouseCHD/Classifier/"$ver"
49-
wget https://zenodo.org/records/"$ver"/files/Classifier.zip
50-
unzip Classifier.zip && rm Classifier.zip
51-
mkdir -p ~/.MouseCHD/HeartSeg/"$ver" && cd ~/.MouseCHD/HearSeg/"$ver"
52-
wget https://zenodo.org/records/"$ver"/files/HeartSeg.zip
53-
unzip HeartSeg.zip && rm HeartSeg.zip && cd ~
43+
wget https://zenodo.org/records/13855119/files/mousechd.sif
5444
```
45+
* On HPC, the internet connection may not be not available on running node, you should download models in advance. See the downloading instruction [here](https://github.com/hnguyentt/MouseCHD/tree/master/containers#apptainer)
5546
* Test if container run correctly: `apptainer exec --nv <path/to/mousechd.sif> mousechd -h`
5647

5748
<details>

containers/README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
## Docker
44

5-
Running docker with GPU requires installing `nvidia-container-toolkit` package. To install on Debian-based OSes:
5+
### Running docker with GPU
6+
Running docker with GPU requires installing `nvidia-container-toolkit` package. If you haven't had it install, following this instruction to install.
7+
8+
On Debian-based OSes:
69
```bash
710
# Add the package repositories
811
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
@@ -14,14 +17,36 @@ $ sudo systemctl restart docker
1417
```
1518
(See: https://stackoverflow.com/a/58432877/11524628) for more details.
1619

20+
### Running `mousechd` with docker
21+
* Pull `mousechd` docker image: `sudo docker pull hoanguyen93/mousechd`
22+
* Append this prefix before every command in the [How to use](https://github.com/hnguyentt/MouseCHD?tab=readme-ov-file#how-to-use): `sudo docker run --gpus all -v /path/on/host:/path/in/container mousechd`
23+
* `--gpus all`: container can see and use all gpus available on host
24+
* `-v /path/on/host:/path/in/container`: mount host data to container. For example, I mount my home folder to container home folder: `-v /home/hnguyent:/homme/hnguyent`
25+
26+
For example, I run [segmentation](https://github.com/hnguyentt/MouseCHD?tab=readme-ov-file#2-heart-segmentation) like this: `sudo docker run --gpus all -v /home/hnguyent:/home/hnguyent mousechd mousechd segment -indir /home/hnguyent/DATA/images -outdir /home/hnguyent/DATA/HeartSeg`
27+
28+
1729
## Apptainer
1830
[Apptainer](https://apptainer.org/) is an open-source containerization tool, designed specifically for High-Performance Computing (HPC) environments. Unlike traditional container solutions like Docker, Apptainer emphasizes **unprivileged execution**, ensuring safe deployment in shared computing infrastructures, where running services as root may pose security risks. Apptainer enables portability of applications across different systems, while allowing access to GPUs, specialized hardware, and libraries.
1931

20-
1. Build Apptainer image
21-
```bash
22-
sudo apptainer build mousechd.sif mousechd.def
32+
### Downloading models in advance on HPC
33+
On HPC, the internet connection may not be available on running node, you should download models in advance, copy and paste in command line on HPC:
34+
35+
```
36+
ver=13785314
37+
mkdir -p ~/.MouseCHD/Classifier/"$ver" && cd ~/.MouseCHD/Classifier/"$ver" && wget https://zenodo.org/records/"$ver"/files/Classifier.zip && unzip Classifier.zip && rm Classifier.zip
38+
mkdir -p ~/.MouseCHD/HeartSeg/"$ver" && cd ~/.MouseCHD/HeartSeg/"$ver" && wget https://zenodo.org/records/"$ver"/files/HeartSeg.zip && unzip HeartSeg.zip && rm HeartSeg.zip && cd ~
2339
```
2440

25-
2. Interact with mousechd
41+
### Run `mousechd` with Apptainer
42+
* Download Apptainer: `wget https://zenodo.org/records/13855119/files/mousechd.sif`
43+
* Download model in advance (only on HPC) like the [instruction above]().
44+
* Append this prefix before every command in the [How to use](https://github.com/hnguyentt/MouseCHD?tab=readme-ov-file#how-to-use): `apptainer exec [-B /path/to/directory/on/host] --nv <path/to/mousechd.sif>`:
45+
* `--nv`: container can see and use available gpus.
46+
* `-B /path/to/directory/on/host`: `B` flag is for binding directories from the host into the container. If your data is not visible by container, especially on HPC, you could use this flag to mount your data to container.
47+
48+
For example, I run [segmentation](https://github.com/hnguyentt/MouseCHD?tab=readme-ov-file#2-heart-segmentation) like this:
49+
50+
* On my local machine: `sapptainer exec --nv mousechd.sif mousechd segment -indir /home/hnguyent/DATA/images -outdir /home/hnguyent/DATA/HeartSeg`.
2651

27-
Append the prefix: `apptainer shell --nv mousechd.sif `
52+
* On HPC, I append additional SLURM prefix to request for computational resources: `srun -J "mousechd" -p gpu --qos=gpu --gres=gpu:1 --cpus-per-task=2 --mem-per-cpu=250000 apptainer exec -B /mount_data --nv mousechd.sif DATA/zeus/hnguyent/images -outdir DATA/zeus/hnguyent/HeartSeg`. Here I need to use `-B` flag to make my data visible in container.

0 commit comments

Comments
 (0)