Table of Contents

Python

Python is one of the most widely used programming languages in scientific computing, and it is well supported on Hábrók. This page describes the recommended way to use Python on the cluster, from loading the right Python version, to managing packages and environments, to running Python jobs and working interactively.

What is different about Python on the cluster?

On your own laptop, you might install Python packages directly with pip install or mamba install , but on the cluster things work a little differently:

The pages in the following section walk you through all of this in detail.

Loading Python
How to find and load Python versions on Hábrók using the module system. Also covers the pre-installed optimised libraries (numpy, scipy, TensorFlow, PyTorch, etc.) and how to check what is already available before installing anything yourself.

Python Environments
On the cluster you work in isolated Python environments. This subsection covers the three main tools for creating and managing these environments:

Running Python Jobs
How to write job scripts that use your Python environment on the cluster. Covers single-CPU jobs, multi-CPU jobs using multiprocessing, GPU jobs, and multi-node MPI jobs.

Python in VSCode
How to use Python modules in VScode.

Jupyter Notebooks
How to run Jupyter notebooks on Hábrók, either through the web portal or via an SSH tunnel to a compute node running a batch job.

Spyder
How to install and run Spyder, a graphical Python IDE for scientific work, using a remote desktop session on the web portal.

Python FAQs

My program output does not appear as expected when I submit a job.

There are two possibilities here. First; your program is not reaching the line where you expect to output something, this is something you will have to solve yourself and preferably test on a local machine. Second; python has buffered your output, then an unexpected crash ate the buffer. This makes debugging certain programs on Hábrók very tough because you might have produced some output but it is not shown because of the way Python handles output to the terminal or in this case the .job file. The easiest solution is to run python with the -u flag, so python -u <my_script> <other_arguments>. There are also some solutions including logging and outputting to stderr instead of stdout.