Skip to content

Commit 11bc500

Browse files
authored
Merge pull request #109 from uvarc/staging
Replacing most refs to Anaconda with Miniforge
2 parents e43840d + 2982169 commit 11bc500

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+482
-114
lines changed

content/courses/containers-for-hpc/using.md

+30-29
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Log on to our HPC cluster
1313
- Run `hdquota`
1414
- Make sure you have a few GBs of free space
1515
- Run `allocations`
16-
- Check if you have `rivanna-training`
16+
- Check if you have `hpc_training`
1717

1818
---
1919

@@ -115,7 +115,7 @@ $ apptainer exec lolcow_latest.sif which fortune
115115

116116
- Apptainer bind mounts these host directories at runtime:
117117
- Personal directories: `/home`, `/scratch`
118-
- Leased storage shared by your research group: `/project`, `/standard`, `/nv`
118+
- Leased storage shared by your research group: `/project`, `/standard`
119119
- Your current working directory
120120
- To bind mount additional host directories/files, use `--bind`/`-B`:
121121

@@ -170,11 +170,11 @@ The corresponding `run` command is displayed upon loading a module.
170170
```bash
171171
$ module load tensorflow
172172
To execute the default application inside the container, run:
173-
apptainer run --nv $CONTAINERDIR/tensorflow-2.10.0.sif
173+
apptainer run --nv $CONTAINERDIR/tensorflow-2.13.0.sif
174174

175175
$ module list
176176
Currently Loaded Modules:
177-
1) apptainer/1.2.2 2) tensorflow/2.10.0
177+
1) apptainer/1.2.2 2) tensorflow/2.13.0
178178
```
179179

180180
- `$CONTAINERDIR` is an environment variable. It is the directory where containers are stored.
@@ -204,45 +204,46 @@ Currently Loaded Modules:
204204
Copy these files:
205205

206206
```bash
207-
cp /share/resources/tutorials/apptainer_ws/tensorflow-2.10.0.slurm .
207+
cp /share/resources/tutorials/apptainer_ws/tensorflow-2.13.0.slurm .
208208
cp /share/resources/tutorials/apptainer_ws/mnist_example.{ipynb,py} .
209209
```
210210

211211
Examine Slurm script:
212212

213213
```bash
214214
#!/bin/bash
215-
#SBATCH -A rivanna-training # account name
216-
#SBATCH -p gpu # partition/queue
217-
#SBATCH --gres=gpu:1 # request 1 gpu
218-
#SBATCH -c 1 # request 1 cpu core
219-
#SBATCH -t 00:05:00 # time limit: 5 min
220-
#SBATCH -J tftest # job name
221-
#SBATCH -o tftest-%A.out # output file
222-
#SBATCH -e tftest-%A.err # error file
223-
215+
#SBATCH -A hpc_training # account name
216+
#SBATCH -p gpu # partition/queue
217+
#SBATCH --gres=gpu:1 # request 1 gpu
218+
#SBATCH -c 1 # request 1 cpu core
219+
#SBATCH -t 00:05:00 # time limit: 5 min
220+
#SBATCH -J tftest # job name
221+
#SBATCH -o tftest-%A.out # output file
222+
#SBATCH -e tftest-%A.err # error file
223+
224+
VERSION=2.13.0
224225
# start with clean environment
225226
module purge
226-
module load apptainer tensorflow/2.10.0
227+
module load apptainer tensorflow/$VERSION
227228
228-
apptainer run --nv $CONTAINERDIR/tensorflow-2.10.0.sif mnist_example.py
229+
apptainer run --nv $CONTAINERDIR/tensorflow-$VERSION.sif mnist_example.py
229230
```
230231

231232
Submit job:
232233

233234
```bash
234-
sbatch tensorflow-2.10.0.slurm
235+
sbatch tensorflow-2.13.0.slurm
235236
```
236237

237238
#### What does `--nv` do?
238239

239240
See [Apptainer GPU user guide](https://apptainer.org/user-docs/master/gpu.html#nvidia-gpus-cuda-standard)
240241

241242
```bash
242-
$ apptainer shell $CONTAINERDIR/tensorflow-2.10.0.sif
243+
$ apptainer shell $CONTAINERDIR/tensorflow-2.13.0.sif
243244
Apptainer> ls /.singularity.d/libs
244245
245-
$ apptainer shell --nv $CONTAINERDIR/tensorflow-2.10.0.sif
246+
$ apptainer shell --nv $CONTAINERDIR/tensorflow-2.13.0.sif
246247
Apptainer> ls /.singularity.d/libs
247248
libEGL.so libGLX.so.0 libnvidia-cfg.so libnvidia-ifr.so
248249
libEGL.so.1 libGLX_nvidia.so.0 libnvidia-cfg.so.1 libnvidia-ifr.so.1
@@ -255,21 +256,21 @@ libEGL.so.1 libGLX_nvidia.so.0 libnvidia-cfg.so.1 libnvidia-ifr.so.
255256

256257
### "Can I use my own container on JupyterLab?"
257258

258-
Suppose you need to use TensorFlow 2.11.0 on JupyterLab. First, note we do not have `tensorflow/2.11.0` as a module:
259+
Suppose you need to use TensorFlow 2.17.0 on JupyterLab. First, note we do not have `tensorflow/2.17.0` as a module:
259260

260261
```bash
261262
module spider tensorflow
262263
```
263264

264-
Go to [TensorFlow's Docker Hub page](https://hub.docker.com/r/tensorflow/tensorflow/tags?page=1&name=2.11.0) and search for the tag (i.e. version). You'll want to use one that has the `-gpu-jupyter` suffix. Pull the container in your account.
265+
Go to [TensorFlow's Docker Hub page](https://hub.docker.com/r/tensorflow/tensorflow) and search for the tag (i.e. version). You'll want to use one that has the `-gpu-jupyter` suffix. Pull the container in your account.
265266

266267
### Installation
267268

268269
#### Manual
269270
1. Create kernel directory
270271

271272
```bash
272-
DIR=~/.local/share/jupyter/kernels/tensorflow-2.11.0
273+
DIR=~/.local/share/jupyter/kernels/tensorflow-2.17.0
273274
mkdir -p $DIR
274275
cd $DIR
275276
```
@@ -279,11 +280,11 @@ cd $DIR
279280
```
280281
{
281282
"argv": [
282-
"/home/<user>/.local/share/jupyter/kernels/tensorflow-2.11.0/init.sh",
283+
"/home/<user>/.local/share/jupyter/kernels/tensorflow-2.17.0/init.sh",
283284
"-f",
284285
"{connection_file}"
285286
],
286-
"display_name": "Tensorflow 2.11",
287+
"display_name": "Tensorflow 2.17",
287288
"language": "python"
288289
}
289290
```
@@ -315,23 +316,23 @@ Usage: jkrollout sif display_name [gpu]
315316
```
316317

317318
```bash
318-
jkrollout /path/to/sif "Tensorflow 2.11" gpu
319+
jkrollout /path/to/sif "Tensorflow 2.17" gpu
319320
```
320321

321322
### Test your new kernel
322323

323-
- Go to https://rivanna-portal.hpc.virginia.edu
324+
- Go to https://ood.hpc.virginia.edu
324325
- Select JupyterLab
325326
- Partition: GPU
326327
- Work Directory: (location of your `mnist_example.ipynb`)
327-
- Allocation: `rivanna-training`
328-
- Select the new "TensorFlow 2.11" kernel
328+
- Allocation: `hpc_training`
329+
- Select the new "TensorFlow 2.17" kernel
329330
- Run `mnist_example.ipynb`
330331

331332
### Remove a custom kernel
332333

333334
```bash
334-
rm -rf ~/.local/share/jupyter/kernels/tensorflow-2.11.0
335+
rm -rf ~/.local/share/jupyter/kernels/tensorflow-2.17.0
335336
```
336337

337338
---

content/courses/fortran-introduction/array_intrinsics.md

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ These create new arrays from old. `PACK` and `UNPACK` can be used to "flatten" m
2525

2626
```fortran
2727
! Convert an array from one shape to another (total size must match)
28+
! SHAPE must be a rank-one array whose elements are sizes in each dimension
2829
RESHAPE(SOURCE,SHAPE[,PAD][,ORDER])
2930
! Combine two arrays of same shape and size according to MASK
3031
! Take from ARR1 where MASK is .true., ARR2 where it is .false.
@@ -37,8 +38,10 @@ SPREAD(SOURCE,DIM,NCOPIES)
3738
```
3839
**Example**
3940
```fortran
41+
!Array and mask are of size NxM
4042
mask=A<0
4143
merge(A,0,mask)
44+
B=reshape(A,(/M,N/))
4245
! for C=1, D=[1,2]
4346
print *, spread(C, 1, 2) ! "1 1"
4447
print *, spread(D, 1, 2) ! "1 1 2 2"
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
program sendrows
2+
use mpi_f08
3+
4+
double precision, allocatable, dimension(:,:) :: u,w
5+
integer :: N
6+
integer :: i,j
7+
8+
integer :: nr, nc
9+
integer :: rank, nprocs, tag=0
10+
integer :: err, errcode
11+
integer :: ncount, blocklength, stride
12+
type(MPI_Status), dimension(:), allocatable :: mpi_status_arr
13+
type(MPI_Request), dimension(:), allocatable :: mpi_requests
14+
type(MPI_Datatype) :: rows
15+
16+
integer, parameter :: root=0
17+
integer :: src, dest
18+
19+
!Initialize MPI, get the local number of columns
20+
call MPI_INIT()
21+
call MPI_COMM_SIZE(MPI_COMM_WORLD,nprocs)
22+
call MPI_COMM_RANK(MPI_COMM_WORLD,rank)
23+
24+
!We will make the matrix scale with number of processes for simplicity
25+
nr=nprocs
26+
nc=nprocs
27+
28+
allocate(u(nr,nc),w(nr,nc))
29+
allocate(mpi_requests(2*nprocs),mpi_status_arr(2*nprocs))
30+
u=0.0d0
31+
w=0.0d0
32+
33+
!Cyclic sending
34+
if (rank == nprocs-1) then
35+
src=rank-1
36+
dest=0
37+
else if (rank==0) then
38+
src=nprocs-1
39+
dest=rank+1
40+
else
41+
src=rank-1
42+
dest=rank+1
43+
endif
44+
45+
ncount=1
46+
blocklength=nc
47+
stride=nr
48+
49+
call MPI_Type_vector(ncount,blocklength,stride,MPI_DOUBLE_PRECISION,rows)
50+
51+
call MPI_TYPE_COMMIT(rows)
52+
53+
do i=0,nprocs-1
54+
if (rank==i) then
55+
tag=i
56+
print *, i,i+1,i+nprocs+1
57+
if (i==0) then
58+
call MPI_Irecv(w(nprocs,1),1,rows,src,tag,MPI_COMM_WORLD,mpi_requests(i+1))
59+
call MPI_Isend(u(i+1,1),1,rows,dest,tag,MPI_COMM_WORLD,mpi_requests(i+nprocs+1))
60+
else if (i==nprocs-1) then
61+
call MPI_Irecv(w(1,1),1,rows,src,tag,MPI_COMM_WORLD,mpi_requests(i+1))
62+
call MPI_Isend(u(nprocs,1),1,rows,dest,tag,MPI_COMM_WORLD,mpi_requests(i+nprocs+1))
63+
else
64+
call MPI_Irecv(w(i+2,1),1,rows,src,tag,MPI_COMM_WORLD,mpi_requests(i+1))
65+
call MPI_Isend(u(i+1,1),1,rows,dest,tag,MPI_COMM_WORLD,mpi_requests(i+nprocs+1))
66+
endif
67+
endif
68+
enddo
69+
70+
call MPI_Waitall(size(mpi_requests),mpi_requests,mpi_status_arr)
71+
72+
73+
call MPI_TYPE_FREE(rows)
74+
75+
!Print neatly
76+
do i=1,nr
77+
write(*,*) "|",u(i,:),"|"," |",w(i,:),"|"
78+
enddo
79+
80+
call MPI_Finalize()
81+
82+
end program
83+
84+
85+
86+

content/courses/parallel-computing-introduction/distributed_mpi_setup.md

+36-8
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,44 @@ menu:
99
parent: Distributed-Memory Programming
1010
---
1111

12+
Using MPI requires access to a computer with at least one node with multiple cores. The Message Passing Interface is a standard and there are multiple implementations of it, so a choice of distribution must be made. Popular implementations include [MPICH](https://www.mpich.org/), [OpenMPI](https://www.open-mpi.org/), [MVAPICH2](https://mvapich.cse.ohio-state.edu/), and [IntelMPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/mpi-library.html#gs.gdkhva). MPICH, OpenMPI, and MVAPICH2 must be built for a system, so a compiler must be chosen as well. IntelMPI is typically used with the Intel compiler and is provided by the vendor as part of their [HPC Toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/hpc-toolkit.html#gs.gdkm8y). MVAPICH2 is a version of MPICH that is specialized for high-speed [Infiniband](https://en.wikipedia.org/wiki/InfiniBand) networks on high-performance clusters, so would generally not be appropriate for installation on individual computers.
13+
1214
### On a Remote Cluster
1315

14-
Refer to the instructions from your site, for example [UVA Research Computing](https://www.rc.virginia.edu/userinfo/howtos/rivanna/mpi-howto/) for our local environment. Nearly always, you will be required to prepare your code and run it through a _resource manager_ such as [Slurm](https://www.rc.virginia.edu/userinfo/rivanna/slurm/).
16+
Refer to the instructions from your site, for example [UVA Research Computing](https://www.rc.virginia.edu/userinfo/howtos/rivanna/mpi-howto/) for our local environment. Nearly always, you will be required to prepare your code and run it through a _resource manager_ such as [Slurm](https://www.rc.virginia.edu/userinfo/rivanna/slurm/). Most HPC sites use a _modules_ system, so generally you will need to load modules for an MPI version and usually the corresponding compiler. It is important to be sure that you use a version of MPI that can communicate correctly with your resource manager.
17+
```bash
18+
module load gcc
19+
module load openmpi
20+
```
21+
is an example setup for compiled-language users.
22+
23+
For Python, the mpi4py package is most widely available. It is generally preferable, and may be required, that mpi4py be installed from the conda-forge repository. On a cluster, mpi4py will need to link to a locally-built version of MPI that can communicate with the resource manager. The conda-forge maintainers provide instructions for this [here](https://conda-forge.org/docs/user/tipsandtricks/#using-external-message-passing-interface-mpi-libraries). In our example, we will use openmpi. First we must load the modules for the compiler and MPI version:
1524

16-
For Python, you will need to install mpi4py. You may wish to create a conda environment for it. On the UVA system you must use `pip` rather than conda.
1725
```bash
1826
module load gcc openmpi
19-
module load anaconda
20-
pip install --user mpi4py
27+
```
28+
We must not install OpenMPI directly from conda-forge; rather we make use of the "hooks" they have provided.
29+
```bash
30+
module list openmpi
31+
```
32+
In our example, the module list returns
33+
```bash
34+
Currently Loaded Modules Matching: openmpi
35+
1) openmpi/4.1.4
36+
```
37+
Now we check that our version of OpenMPI is available
38+
```bash
39+
conda search -f openmpi -c conda-forge
40+
```
41+
Most versions are there, so we can install the one we need
42+
```bash
43+
conda install -c conda-forge "openmpi=4.1.4=external_*"
44+
```
45+
Be sure to include the `external_*` string.
46+
47+
After this completes, we can install mpi4py
48+
```bash
49+
conda install -c conda-forge mpi4py
2150
```
2251

2352
### On a Local Computer
@@ -32,7 +61,7 @@ The author of mpi4py [recommends](https://mpi4py.readthedocs.io/en/stable/instal
3261
```no-highlight
3362
python -m pip install mpi4py
3463
```
35-
This may avoid some issues that occasionally arise in prebuilt mpi4py packages. Be sure that an appropriate `mpicc` executable is in the path. Alternatively, use the `conda-forge` channel (recommended in general for most scientific software).
64+
This may avoid some issues that occasionally arise in prebuilt mpi4py packages. Be sure that an appropriate `mpicc` executable is in the path. Alternatively, use the `conda-forge` channel (recommended in general for most scientific software). Most of the time, if you are installing mpi4py from conda-forge, you can simply install the package. MPICH is the default when installed as a prerequisite for conda-forge.
3665

3766
#### Linux
3867

@@ -47,7 +76,7 @@ Installing the HPC Toolkit will also install IntelMPI.
4776
_NVIDIA HPC SDK_
4877
The NVIDIA software ships with a precompiled version of OpenMPI.
4978

50-
The headers and libraries for MPI _must_ match. Using a header from one MPI and libraries from another, or using headers from a version from one compiler and libraries from a different compiler, usually results in some difficult-to-interpret bugs. Moreover, the process manager must be compatible with the MPI used to compile the code. Because of this, if more than one compiler and especially more than one MPI version is installed, the use of _modules_ ([environment modules](http://modules.sourceforge.net/) or [lmod](https://lmod.readthedocs.io/en/latest/)) becomes particularly beneficial. Both Intel and NVIDIA provide scripts for the environment modules package (lmod can also read these), with possibly some setup required. If you plan to use mpi4py as well as compiled-language versions, creating a module for your Python distribution would also be advisable.
79+
The headers and libraries for MPI _must_ match. Using a header from one MPI and libraries from another, or using headers from a version from one compiler and libraries from a different compiler, usually results in some difficult-to-interpret bugs. Moreover, the process manager must be compatible with the MPI used to compile the code. Because of this, if more than one compiler and especially more than one MPI version is installed, the use of _modules_ ([environment modules](http://modules.sourceforge.net/) or [lmod](https://lmod.readthedocs.io/en/latest/)) becomes particularly beneficial. Both Intel and NVIDIA provide scripts for the environment modules package (lmod can also read these), with possibly some setup required. If you plan to use mpi4py as well as compiled-language versions, creating a module for your Python distribution would also be advisable. Installation of a module system on an individual Linux system is straightforward for an administrator with some experience.
5180

5281
#### Mac OS
5382

@@ -63,7 +92,7 @@ The NVIDIA suite is not available for Mac OS.
6392
#### Windows
6493

6594
_GCC_
66-
The simplest way to use OpenMPI on Windows is through [Cygwin](https://www.cygwin.com/). In this case, the gcc compiler suite would first be installed, with g++ and/or gfortran added. Then the openmpi package could also be installed through the cygwin package manager.
95+
The easiest way to use OpenMPI on Windows is through [Cygwin](https://www.cygwin.com/). In this case, the gcc compiler suite would first be installed, with g++ and/or gfortran added. Then the openmpi package could also be installed through the cygwin package manager.
6796

6897
_Intel oneAPI_
6998
Install the HPC Toolkit.
@@ -74,4 +103,3 @@ Download the package when it is available.
74103
MPI codes must generally be compiled and run through a command line on Windows. Cygwin users can find a variety of tutorials online, for example [here](https://www.youtube.com/watch?v=ENH70zSaztM).
75104

76105
The Intel oneAPI Basic Toolkit includes a customized command prompt in its folder in the Apps menu.
77-

0 commit comments

Comments
 (0)