Skip to content

Commit 65cf901

Browse files
committed
made another pass on OOD
1 parent 93ccedf commit 65cf901

3 files changed

Lines changed: 71 additions & 56 deletions

File tree

docs/hpc/09_ood/01_open_on_demand.md

Lines changed: 71 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ If you're not on the NYU network, you may need to connect via NYU's Virtual Priv
1010
This page describes how to use your Singularity with conda environment in Open OnDemand (OOD) GUI at Greene.
1111

1212
### Log Into Greene via the Terminal
13-
The following commands must be run from the terminal. Information on accessing via the terminal can be found at the [Connecting to the HPC page](../02_connecting_to_hpc/01_connecting_to_hpc.mdx).
13+
The following commands must be run from the terminal. Information on accessing via the terminal can be found at [Connecting to the HPC](../02_connecting_to_hpc/01_connecting_to_hpc.mdx).
1414

1515
### Preinstallation Warning
1616
:::warning
1717
If you have initialized Conda in your base environment, your prompt on Greene may show something like:
1818
```sh
19-
(base) [NETID@log-1 ~]$
19+
(base) [NetID@log-1 ~]$
2020
```
2121
then you must first comment out or remove this portion of your `~/.bashrc` file:
2222

@@ -41,116 +41,122 @@ The above code automatically makes your environment look for the default shared
4141
:::
4242

4343
### Prepare Overlay File
44-
```sh
45-
mkdir /scratch/$USER/my_env
46-
cd /scratch/$USER/my_env
47-
cp -rp /scratch/work/public/overlay-fs-ext3/overlay-15GB-500K.ext3.gz .
48-
gunzip overlay-15GB-500K.ext3.gz
44+
```bash
45+
[NetID@log-1 ~]$ mkdir /scratch/$USER/my_env
46+
[NetID@log-1 ~]$ cd /scratch/$USER/my_env
47+
[NetID@log-1 my_env]$ cp -rp /scratch/work/public/overlay-fs-ext3/overlay-15GB-500K.ext3.gz .
48+
[NetID@log-1 my_env]$ gunzip overlay-15GB-500K.ext3.gz
4949
```
50-
Above we used the overlay file "overlay-15GB-500K.ext3.gz" which will contain all of the installed packages. There are more optional overlay files. You can find instructions on the following pages: [Singularity with Conda](../07_containers/03_singularity_with_conda.md), [Squash File System and Singularity](../07_containers/04_squash_file_system_and_singularity.md).
50+
Above we used the overlay file `overlay-15GB-500K.ext3.gz` which will contain all of the installed packages. There are more optional overlay files. You can find instructions on the following pages: [Singularity with Conda](../07_containers/03_singularity_with_conda.md), [Squash File System and Singularity](../07_containers/04_squash_file_system_and_singularity.md).
5151

5252
### Launch Singularity Environment for Installation
53-
```sh
54-
singularity exec --overlay /scratch/$USER/my_env/overlay-15GB-500K.ext3:rw /scratch/work/public/singularity/cuda12.3.2-cudnn9.0.0-ubuntu-22.04.4.sif /bin/bash
53+
```bash
54+
[NetID@log-1 ~]$ singularity exec --overlay /scratch/$USER/my_env/overlay-15GB-500K.ext3:rw /scratch/work/public/singularity/cuda12.3.2-cudnn9.0.0-ubuntu-22.04.4.sif /bin/bash
5555
```
56-
Above we used the Singularity OS image "cuda12.3.2-cudnn9.0.0-ubuntu-22.04.4.sif " which provides the base operating system environment for the conda environment. There are other Singularity OS images available at `/scratch/work/public/singularity`
56+
Above we used the Singularity OS image `cuda12.3.2-cudnn9.0.0-ubuntu-22.04.4.sif` which provides the base operating system environment for the conda environment. There are other Singularity OS images available at `/scratch/work/public/singularity`
5757

58-
Launching Singularity with the --overlay flag mounts the overlay file to a new directory: /ext3 - you will notice that when not using Singularity /ext3 is not available. Be sure that you have the Singularity prompt (Singularity>) and that /ext3 is available before the next step:
58+
Launching Singularity with the `--overlay` flag mounts the overlay file to a new directory: `/ext3` - you will notice that when not using Singularity `/ext3` is not available.
59+
60+
:::warning
61+
Be sure that you have the Singularity prompt (`Singularity>`) and that `/ext3` is available before the next step.
5962
```sh
6063
Singularity> ls -lah /ext3
6164
total 8.5K
6265
drwxrwxr-x. 2 root root 4.0K Oct 19 10:01 .
6366
drwx------. 29 root root 8.0K Oct 19 10:01 ..
6467
```
68+
:::
6569

6670
### Install Miniforge to Overlay File
67-
```sh
68-
wget --no-check-certificate https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
69-
sh Miniforge3-Linux-x86_64.sh -b -p /ext3/miniforge3
71+
```bash
72+
Singularity> wget --no-check-certificate https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
73+
Singularity> sh Miniforge3-Linux-x86_64.sh -b -p /ext3/miniforge3
7074
```
71-
Next, create a wrapper script at /ext3/env.sh
72-
```sh
73-
touch /ext3/env.sh
74-
echo '#!/bin/bash' >> /ext3/env.sh
75-
echo 'unset -f which' >> /ext3/env.sh
76-
echo 'source /ext3/miniforge3/etc/profile.d/conda.sh' >> /ext3/env.sh
77-
echo 'export PATH=/ext3/miniforge3/bin:$PATH' >> /ext3/env.sh
78-
echo 'export PYTHONPATH=/ext3/miniforge3/bin:$PATH' >> /ext3/env.sh
79-
```
80-
Your /ext3/env.sh file should now contain the following:
75+
Next, create a wrapper script at `/ext3/env.sh`:
76+
```bash
77+
Singularity> touch /ext3/env.sh
78+
Singularity> echo '#!/bin/bash' >> /ext3/env.sh
79+
Singularity> echo 'unset -f which' >> /ext3/env.sh
80+
Singularity> echo 'source /ext3/miniforge3/etc/profile.d/conda.sh' >> /ext3/env.sh
81+
Singularity> echo 'export PATH=/ext3/miniforge3/bin:$PATH' >> /ext3/env.sh
82+
Singularity> echo 'export PYTHONPATH=/ext3/miniforge3/bin:$PATH' >> /ext3/env.sh
83+
```
84+
Your `/ext3/env.sh` file should now contain the following:
8185
```bash
8286
#!/bin/bash
83-
unset -f which
87+
unset -f which
8488
source /ext3/miniforge3/etc/profile.d/conda.sh
8589
export PATH=/ext3/miniforge3/bin:$PATH
8690
export PYTHONPATH=/ext3/miniforge3/bin:$PATH
8791
```
8892
The wrapper script will activate your conda environment, to which you will be installing your packages and dependencies.
8993

9094
Next, activate your conda environment with the following:
91-
```sh
92-
source /ext3/env.sh
95+
```bash
96+
Singularity> source /ext3/env.sh
9397
```
9498

9599
### Install Packages to Miniforge Environment
96-
Now that your environment is activated, you can update and install packages
97-
```sh
98-
conda config --remove channels defaults
99-
conda update -n base conda -y
100-
conda clean --all --yes
101-
conda install pip --yes
102-
conda install ipykernel --yes # Note: ipykernel is required to run as a kernel in the Open OnDemand Jupyter Notebooks
100+
Now that your environment is activated, you can update and install packages:
101+
```bash
102+
Singularity> conda config --remove channels defaults
103+
Singularity> conda update -n base conda -y
104+
Singularity> conda clean --all --yes
105+
Singularity> conda install pip --yes
106+
Singularity> conda install ipykernel --yes # Note: ipykernel is required to run as a kernel in the Open OnDemand Jupyter Notebooks
103107
```
104108
To confirm that your environment is appropriately referencing your Miniforge installation, try out the following:
105-
```sh
106-
unset which
107-
which conda
109+
```bash
110+
Singularity> unset which
111+
Singularity> which conda
108112
# output: /ext3/miniforge3/bin/conda
109113

110-
which python
114+
Singularity> which python
111115
# output: /ext3/miniforge3/bin/python
112116

113-
python --version
114-
# output: Python 3.8.5
117+
Singularity> python --version
118+
# output: Python 3.12.9
115119

116-
which pip
120+
Singularity> which pip
117121
# output: /ext3/miniforge3/bin/pip
118122
```
119123

120-
Now use either conda install or pip to install your required python packages to the Miniforge environment.
124+
Now use either conda or pip to install your required python packages to the Miniforge environment.
121125

122126
To install larger packages, like Tensorflow, you must first start an interactive job with adequate compute and memory resources to install packages. The login nodes restrict memory to 2GB per user, which may cause some large packages to crash.
123-
```sh
124-
srun --cpus-per-task=2 --mem=10GB --time=04:00:00 --pty /bin/bash
127+
```bash
128+
Singularity> exit
129+
130+
[NetID@log-1 my_env]$ srun --cpus-per-task=2 --mem=10GB --time=04:00:00 --pty /bin/bash
125131

126132
# wait to be assigned a node
127133

128-
singularity exec --overlay /scratch/$USER/my_env/overlay-15GB-500K.ext3:rw /scratch/work/public/singularity/cuda12.3.2-cudnn9.0.0-ubuntu-22.04.4.sif /bin/bash
134+
[NetID@cm001 my_env]$ singularity exec --overlay /scratch/$USER/my_env/overlay-15GB-500K.ext3:rw /scratch/work/public/singularity/cuda12.3.2-cudnn9.0.0-ubuntu-22.04.4.sif /bin/bash
129135

130-
source /ext3/env.sh
136+
Singularity> source /ext3/env.sh
131137
# activate the environment
132138
```
133139

134140
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.
135141

136142
### Configure iPython Kernels
137143
To create a kernel named my_env copy the template files to your home directory.
138-
```sh
139-
mkdir -p ~/.local/share/jupyter/kernels
140-
cd ~/.local/share/jupyter/kernels
141-
cp -R /share/apps/mypy/src/kernel_template ./my_env # this should be the name of your Singularity env
142-
cd ./my_env
144+
```bash sh
145+
Singularity> mkdir -p ~/.local/share/jupyter/kernels
146+
Singularity> cd ~/.local/share/jupyter/kernels
147+
Singularity> cp -R /share/apps/mypy/src/kernel_template ./my_env # this should be the name of your Singularity env
148+
Singularity> cd ./my_env
143149

144-
ls
150+
Singularity> ls
145151
#kernel.json logo-32x32.png logo-64x64.png python # files in the ~/.local/share/jupyter/kernels directory
146152
```
147153

148-
To set the conda environment, edit the file named 'python' in /.local/share/jupyter/kernels/my_env/.
154+
To set the conda environment, edit the file named `python` in `/.local/share/jupyter/kernels/my_env/`.
149155

150156
The python file is a wrapper script that the Jupyter notebook will use to launch your Singularity container and attach it to the notebook.
151157

152158
At the bottom of the file we have the template singularity command.
153-
```sh
159+
```bash
154160
singularity exec $nv \
155161
--overlay /scratch/$USER/my_env/overlay-15GB-500K.ext3:ro \
156162
/scratch/work/public/singularity/cuda12.3.2-cudnn9.0.0-ubuntu-22.04.4.sif \
@@ -160,7 +166,7 @@ singularity exec $nv \
160166
If you used a different overlay (/scratch/$USER/my_env/overlay-15GB-500K.ext3 shown above) or .sif file (/scratch/work/public/singularity/cuda12.3.2-cudnn9.0.0-ubuntu-22.04.4.sif shown above), you MUST change those lines in the command above to the files you used.
161167
:::
162168

163-
Edit the default kernel.json file by setting PYTHON_LOCATION and KERNEL_DISPLAY_NAME using a text editor like nano/vim.
169+
Edit the default `kernel.json` file by setting PYTHON_LOCATION and KERNEL_DISPLAY_NAME using a text editor like nano/vim.
164170
```json
165171
{
166172
"argv": [
@@ -194,3 +200,12 @@ Update the `"<Your NetID>"` to your own NetID without the `"<>"` symbols.
194200
[https://ood.hpc.nyu.edu](https://ood.hpc.nyu.edu)
195201

196202
![OOD Launch](./static/OOD_launch.png)
203+
204+
### Configure and Launch your Notebook
205+
206+
![Configure Notebook](./static/configure_notebook.png)
207+
208+
### Select kernel
209+
Once configured and launched, kernels can be selected in the "New" dropdown or within the notebook under the kernel menu. Please note that your notebook view may look slightly different depending on available directories and environments, as well as if you choose the lab or traditional notebook view.
210+
211+
![Select Kernel](./static/select_kernel.png)
134 KB
Loading
5.36 KB
Loading

0 commit comments

Comments
 (0)