Skip to content

Commit 6ca4526

Browse files
authored
Merge pull request #232 from NYU-RTS/mdweisner-patch-1
Update 03_singularity_with_conda.md
2 parents 46d119a + 25ff545 commit 6ca4526

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

docs/hpc/07_containers/03_singularity_with_conda.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,30 @@ Create a directory for the environment:
3939
```
4040
Copy an appropriate gzipped overlay images from the overlay directory. You can browse available images to see available options:
4141
```bash
42-
[NetID@log-1 pytorch-example]$ ls /scratch/work/public/overlay-fs-ext3
42+
[NetID@log-1 pytorch-example]$ ls /share/apps/overlay-fs-ext3
4343
```
4444
In this example we use `overlay-15GB-500K.ext3.gz` as it has enough available storage for most conda environments. It has 15GB free space inside and is able to hold 500K files
4545
You can use another size as needed.
4646
```bash
47-
[NetID@log-1 pytorch-example]$ cp -rp /scratch/work/public/overlay-fs-ext3/overlay-15GB-500K.ext3.gz .
47+
[NetID@log-1 pytorch-example]$ cp -rp /share/apps/overlay-fs-ext3/overlay-15GB-500K.ext3.gz .
4848
[NetID@log-1 pytorch-example]$ gunzip overlay-15GB-500K.ext3.gz
4949
```
5050

5151
Choose a corresponding Singularity image. For this example we will use the following image:
5252
```bash
53-
/scratch/work/public/singularity/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif
53+
/share/apps/images/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif
5454
```
5555

5656
For Singularity image available on nyu HPC Torch, please check the singularity images folder:
5757
```sh
58-
[NetID@log-1 pytorch-example]$ ls /scratch/work/public/singularity/
58+
[NetID@log-1 pytorch-example]$ ls /share/apps/images/
5959
```
6060

6161
For the most recent supported versions of PyTorch, please check the [PyTorch website](https://pytorch.org/get-started/locally/).
6262

6363
Launch the appropriate Singularity container in read/write mode (with the :rw flag):
6464
```sh
65-
singularity exec --overlay overlay-15GB-500K.ext3:rw /scratch/work/public/singularity/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif /bin/bash
65+
singularity exec --overlay overlay-15GB-500K.ext3:rw /share/apps/images/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif /bin/bash
6666
```
6767

6868
The above starts a bash shell inside the referenced Singularity Container overlaid with the 15GB 500K you set up earlier. This creates the functional illusion of having a writable filesystem inside the typically read-only Singularity container.
@@ -143,7 +143,7 @@ The login nodes restrict memory to 2GB per user, which may cause some large pack
143143
After it is running, you’ll be redirected to a compute node. From there, run singularity to setup on conda environment, same as you were doing on login node:
144144

145145
```sh
146-
[NetID@cm001 pytorch-example]$ singularity exec --overlay overlay-15GB-500K.ext3:rw /scratch/work/public/singularity/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif /bin/bash
146+
[NetID@cm001 pytorch-example]$ singularity exec --overlay overlay-15GB-500K.ext3:rw /share/apps/images/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif /bin/bash
147147

148148
Singularity> source /ext3/env.sh
149149
# activate the environment
@@ -174,7 +174,7 @@ Singularity> exit
174174
```
175175
#### Test your PyTorch Singularity Image
176176
```sh
177-
[NetID@cm001 pytorch-example]$ singularity exec --overlay /scratch/<NetID>/pytorch-example/my_pytorch.ext3:ro /scratch/work/public/singularity/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif /bin/bash -c 'source /ext3/env.sh; python -c "import torch; print(torch.__file__); print(torch.__version__)"'
177+
[NetID@cm001 pytorch-example]$ singularity exec --overlay /scratch/<NetID>/pytorch-example/my_pytorch.ext3:ro /share/apps/images/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif /bin/bash -c 'source /ext3/env.sh; python -c "import torch; print(torch.__file__); print(torch.__version__)"'
178178

179179
#output: /ext3/miniforge3/lib/python3.8/site-packages/torch/__init__.py
180180
#output: 2.7.1+cu126
@@ -223,7 +223,7 @@ module purge
223223

224224
singularity exec --nv \
225225
--overlay /scratch/<NetID>/pytorch-example/my_pytorch.ext3:ro \
226-
/scratch/work/public/singularity/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif\
226+
/share/apps/images/singularity/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif\
227227
/bin/bash -c "source /ext3/env.sh; python torch-test.py"
228228
```
229229

@@ -249,7 +249,7 @@ Check your SLURM output for results, an example is shown below:
249249
### Optional: Convert ext3 to a compressed, read-only squashfs filesystem
250250
Singularity images can be compressed into read-only squashfs filesystems to conserve space in your environment. Use the following steps to convert your ext3 Singularity image into a smaller squashfs filesystem.
251251
```sh
252-
[NetID@log-1 pytorch-example]$ srun -N1 -c4 singularity exec --overlay my_pytorch.ext3:ro /scratch/work/public/singularity/centos-8.2.2004.sif mksquashfs /ext3 /scratch/<NetID>/pytorch-example/my_pytorch.sqf -keep-as-directory -processors 4 -noappend
252+
[NetID@log-1 pytorch-example]$ srun -N1 -c4 singularity exec --overlay my_pytorch.ext3:ro /share/apps/images/centos-8.2.2004.sif mksquashfs /ext3 /scratch/<NetID>/pytorch-example/my_pytorch.sqf -keep-as-directory -processors 4 -noappend
253253
```
254254

255255
Here is an example of the amount of compression that can be realized by converting:
@@ -265,7 +265,7 @@ Notice that it saves over 3GB of storage in this case, though your results may v
265265

266266
You can use squashFS images similarly to the ext3 images:
267267
```sh
268-
[NetID@log-1 pytorch-example]$ singularity exec --overlay /scratch/<NetID>/pytorch-example/my_pytorch.sqf:ro /scratch/work/public/singularity/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif /bin/bash -c 'source /ext3/env.sh; python -c "import torch; print(torch.__file__); print(torch.__version__)"'
268+
[NetID@log-1 pytorch-example]$ singularity exec --overlay /scratch/<NetID>/pytorch-example/my_pytorch.sqf:ro /share/apps/images/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif /bin/bash -c 'source /ext3/env.sh; python -c "import torch; print(torch.__file__); print(torch.__version__)"'
269269

270270
#example output: /ext3/miniforge3/lib/python3.12/site-packages/torch/__init__.py
271271
#example output: 2.6.0+cu124
@@ -277,10 +277,10 @@ If the first ext3 overlay image runs out of space or you are using a squashFS co
277277

278278
Open the first image in read only mode:
279279
```sh
280-
[NetID@log-1 pytorch-example]$ cp -rp /scratch/work/public/overlay-fs-ext3/overlay-2GB-100K.ext3.gz .
280+
[NetID@log-1 pytorch-example]$ cp -rp /share/apps/overlay-fs-ext3/overlay-2GB-100K.ext3.gz .
281281
[NetID@log-1 pytorch-example]$ gunzip overlay-2GB-100K.ext3.gz
282282

283-
[NetID@log-1 pytorch-example]$ singularity exec --overlay overlay-2GB-100K.ext3 --overlay /scratch/<NetID>/pytorch-example/my_pytorch.ext3:ro /scratch/work/public/singularity/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif /bin/bash
283+
[NetID@log-1 pytorch-example]$ singularity exec --overlay overlay-2GB-100K.ext3 --overlay /scratch/<NetID>/pytorch-example/my_pytorch.ext3:ro /share/apps/images/cuda12.1.1-cudnn8.9.0-devel-ubuntu22.04.2.sif /bin/bash
284284
Singularity> source /ext3/env.sh
285285
Singularity> pip install tensorboard
286286
```
@@ -303,7 +303,7 @@ Create a directory for your Julia work, such as `/scratch/<NetID>/julia`, and th
303303

304304
Copy an overlay image, such as the 2GB 100K overlay, which generally has enough storage for Julia packages. Once copied, unzip to the same folder, rename to julia-pkgs.ext3:
305305
```sh
306-
[NetID@log-1 julia]$ cp -rp /scratch/work/public/overlay-fs-ext3/overlay-2GB-100K.ext3.gz .
306+
[NetID@log-1 julia]$ cp -rp /share/apps/overlay-fs-ext3/overlay-2GB-100K.ext3.gz .
307307
[NetID@log-1 julia]$ gunzip overlay-2GB-100K.ext3.gz
308308
[NetID@log-1 julia]$ mv overlay-2GB-100K.ext3 julia-pkgs.ext3
309309
```
@@ -478,7 +478,7 @@ Building on the previous Julia example, this will demonstrate how to set up a si
478478

479479
Copy overlay image:
480480
```sh
481-
[NetID@log-1 julia]$ cp -rp /scratch/work/public/overlay-fs-ext3/overlay-2GB-100K.ext3.gz .
481+
[NetID@log-1 julia]$ cp -rp /share/apps/overlay-fs-ext3/overlay-2GB-100K.ext3.gz .
482482
[NetID@log-1 julia]$ gunzip overlay-2GB-100K.ext3.gz
483483
[NetID@log-1 julia]$ mv overlay-2GB-100K.ext3 julia-pkgs.ext3
484484
```
@@ -507,7 +507,7 @@ Launch Singularity with overlay images in writable mode to install packages:
507507
--bind /share/apps \
508508
--bind /scratch/<NetID>/julia/julia-compiled:/ext3/pkgs/compiled \
509509
--bind /scratch/<NetID>/julia/julia-logs:/ext3/pkgs/logs \
510-
/scratch/work/public/apps/torch/centos-8.2.2004.sif \
510+
/share/apps/images/centos-8.2.2004.sif \
511511
/bin/bash
512512
```
513513

@@ -569,7 +569,7 @@ singularity exec \
569569
--bind /share/apps \
570570
--bind /scratch/<NetID>/julia/julia-compiled:/ext3/pkgs/compiled \
571571
--bind /scratch/<NetID>/julia/julia-logs:/ext3/pkgs/logs \
572-
/scratch/work/public/apps/torch/centos-8.2.2004.sif \
572+
/share/apps/images/centos-8.2.2004.sif \
573573
/bin/bash -c "
574574
source /ext3/env.sh
575575
julia $args
@@ -629,7 +629,7 @@ singularity exec \
629629
--bind /share/apps \
630630
--bind /scratch/<NetID>/julia/julia-compiled:/ext3/pkgs/compiled \
631631
--bind /scratch/<NetID>/julia/julia-logs:/ext3/pkgs/logs \
632-
/scratch/work/public/apps/torch/centos-8.2.2004.sif \
632+
/share/apps/images/centos-8.2.2004.sif \
633633
/bin/bash -c "
634634
source /ext3/env.sh
635635
julia $args
@@ -649,7 +649,7 @@ Install packages to the writable image:
649649

650650
If you do not need host packages installed in `/share/apps`, you can work with Singularity OS image:
651651
```sh
652-
/scratch/work/public/singularity/ubuntu-20.04.1.sif
652+
/share/apps/images/ubuntu-20.04.1.sif
653653
```
654654

655655
Download Julia installation package from [https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.3-linux-x86_64.tar.gz](https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.3-linux-x86_64.tar.gz)

0 commit comments

Comments
 (0)