Skip to content

Commit d6768b3

Browse files
committed
testing
1 parent 7ba5e54 commit d6768b3

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

docs/hpc/09_ood/02_jupyter_with_conda_singularity.mdx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,48 @@ Singularity> python --version
114114
Singularity> which pip
115115
# output: /ext3/miniforge3/bin/pip
116116
```
117+
118+
Now use either conda or pip to install your required python packages to the Miniforge environment.
119+
120+
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.
121+
```bash
122+
Singularity> exit
123+
124+
[NetID@log-1 my_env]$ srun --cpus-per-task=2 --mem=10GB --time=04:00:00 --pty /bin/bash
125+
126+
# wait to be assigned a node
127+
128+
[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
129+
130+
Singularity> source /ext3/env.sh
131+
# activate the environment
132+
```
133+
134+
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.
135+
136+
### Configure iPython Kernels
137+
To create a kernel named my_env copy the template files to your home directory.
138+
```bash sh
139+
Singularity> mkdir -p ~/.local/share/jupyter/kernels
140+
Singularity> cd ~/.local/share/jupyter/kernels
141+
Singularity> cp -R /share/apps/mypy/src/kernel_template ./my_env # this should be the name of your Singularity env
142+
Singularity> cd ./my_env
143+
144+
Singularity> ls
145+
#kernel.json logo-32x32.png logo-64x64.png python # files in the ~/.local/share/jupyter/kernels directory
146+
```
147+
148+
To set the conda environment, edit the file named `python` in `/.local/share/jupyter/kernels/my_env/`.
149+
150+
The python file is a wrapper script that the Jupyter notebook will use to launch your Singularity container and attach it to the notebook.
151+
152+
At the bottom of the file we have the template singularity command.
153+
```bash
154+
singularity exec $nv \
155+
--overlay /scratch/$USER/my_env/overlay-15GB-500K.ext3:ro \
156+
/scratch/work/public/singularity/cuda12.3.2-cudnn9.0.0-ubuntu-22.04.4.sif \
157+
/bin/bash -c "source /ext3/env.sh; $cmd $args"
158+
```
159+
:::warning
160+
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.
161+
:::

0 commit comments

Comments
 (0)