Exercises

Isolated

Create a virtual environment with a requirements file below

  • Create a virtual environment with Python 3.11.X (check what is available on your cluster) with the name analysis.

  • Install packages defined by the requirements.txt file (save it).

numpy==1.22.3
matplotlib==3.5.2
pandas==1.4.2
  • Check that the packages were installed.

  • Don’t forget to deactivate afterwards.

Conda (UPPMAX)

UPPMAX: Create a conda environment and install some packages

  • Be sure to deactivate any virtual environment.

  • First check the current installed packages while having python/3.11.8 loaded

  • Open a new terminal and have the old one available for later comparison

  • Use the conda module on Rackham and create an environment with name HPC-python24 with python 3.11 and numpy 1.22

    • Use your a path for CONDA_ENVS_PATH of your own choice or /proj/naiss2024-22-107/<user>/python

    • (It may take a minute or so)

  • Activate!

  • Check with pip list what is there. Compare with the environment given from the python module in the first terminal window.

    • Which version of Python did you get?

  • Don’t forget to deactivate the Conda environment before doing other exercises!

Batch

Run the first serial example script from further up on the page for this short Python code (sum-2args.py)

import sys

x = int(sys.argv[1])
y = int(sys.argv[2])

sum = x + y

print("The sum of the two numbers is: {0}".format(sum))

Remember to give the two arguments to the program in the batch script.