Python Guide

Loading the Python module

For either method, you must first load the python module. Get a list of available versions using:

module avail python

For example, to load Python 3.10.5 you would then run:

module load python/3.10.5

Submitting Jobs

Serial

Create a toy Python example script my_program.py:

print("Hello world")

Create the SLURM submission script submit.sh:

MPI

Please read Laurent Duchesne's excellent step-by-step guide for parallelizing your Python code using multiple processors and MPI.

On our cluster, to run MPI Python programs, mpi4py has been compiled against OpenMPI 1.10.1 therefore we need to load that additional package:

Create the the test MPI example file as described in Laurent's guide above, using the same name mpi.py:

Create the SLURM submission script submit.sh:

You should get output similar to:

Craig Finch has a more practical example for high throughput MPI on GitHub.

Installing Python libraries

Local package install

One can easily install Python packages to your home directory using:

Alternatively, one can install miniconda in their home directory to manage python libraries and environments. This is often preferred by Storrs HPC researchers because it allows users to manage different python environments that would normally be incompatible if installed with pip. A full guide on installing miniconda and then using it to manage python libraries can be found here.

Jupyter notebooks

A few reasons why you may want to use Jupyter notebooks on the cluster are:

  1. Plotting data.

  2. Being productive in the same familiar environment as your personal laptop, quickly edit code and preserve the output alongside that code.

  3. Integrating functions into a larger reusable script by first interactively using cluster-specific installed python libraries and environmental variables.

JupyterHub?

Summary

Current Supported Python Versions

3.7.3, 3.10.5

Check Installed Packages

One can ls all the python directories to see a package is installed:

If you already have a python module loaded, one can also see all the packages and versions installed with:

Latest Installed Packages List

  1. Tensorflow: it already been installed in python 2.7.6. Currently, the cpu version is available. It has been passed our basic testings.

  1. scikit-learn (0.17.1)