Reference for Learners

Course Materials

All course materials are organized in the content/ directory:

  • Episodes: Jupyter notebooks with hands-on examples

  • Code Examples: Supporting Python scripts in episodes/code/

  • Images: Diagrams and visualizations in episodes/images/

  • Solutions: Example solutions in solution/

  • Datasets: Sample data in dataset/

HPC Resources

Karolina Supercomputer

The Karolina supercomputer is available for hands-on sessions:

  • Location: IT4Innovations, Czech Republic

  • Performance: 11.6 PFlop/s (standard), 360 PFlop/s (GPU-accelerated)

  • Access: Through job submission via SLURM

Installation & Setup

  1. Python Environment:

    conda create -n python-hpc python=3.11
    conda activate python-hpc
    pip install -r requirements.txt
    
  2. Container-based Setup (using Apptainer/Singularity):

    • See content/resources/*.def files for container definitions

    • Build: apptainer build image.sif image.def

    • Run: apptainer exec image.sif python script.py

  3. Module Loading (on HPC clusters):

    module load Python/3.11
    module load CUDA  # for GPU computing
    

Key Topics Covered

Performance Optimization

  • Profiling: Identifying bottlenecks using cProfile, line_profiler

  • Benchmarking: Measuring execution time and resource usage

  • NumPy: Vectorization and array operations for speed

Parallel Programming

  • Dask: Task-based parallelization for distributed computing

  • Numba: JIT compilation for CPU optimization

  • Cython: C-extensions for performance-critical code

  • MPI: Message Passing Interface for distributed memory systems

HPC Job Management

  • SLURM: Job scheduling on supercomputers

  • Batch Scripts: Writing and submitting job submissions

  • Job Monitoring: Tracking resource usage and job status

Code Examples

Running Benchmarking Scripts

python content/episodes/code/dist.py        # Performance distribution example
python content/episodes/code/example.py     # General example

MPI Examples

# Run with OpenMPI
mpirun -np 4 python content/episodes/code/mpi-test.py
./content/episodes/code/hello_mpi.sh        # Simple MPI test

Numba JIT Compilation

from numba import jit
import numpy as np

@jit(nopython=True)
def fast_function(x):
    return x ** 2

result = fast_function(np.array([1, 2, 3]))

Dask Distributed Computing

import dask.array as da

# Create a Dask array
x = da.random.random((1000, 1000), chunks=(100, 100))
result = x + x.T
computed = result.compute()

Common Issues & Solutions

Import Errors

  • Ensure all packages are installed: pip install -r requirements.txt

  • Activate the correct virtual environment

  • Check that module paths are correctly set

MPI Not Found

  • Load the MPI module: module load OpenMPI

  • Install mpi4py: pip install mpi4py

Performance Not Improving

  • Profile your code first using cProfile or line_profiler

  • Use appropriate optimization techniques for identified bottlenecks

  • Consider algorithmic improvements alongside code optimization

Container Issues

  • Ensure Apptainer/Singularity is installed: apptainer --version

  • Check container definition files in content/resources/

  • Use --nv flag for GPU-enabled containers: apptainer run --nv image.sif

External Resources

Documentation

Performance & Optimization

HPC & Parallel Programming

Training Materials

Getting Help

  • Consult the instructor-guide.md for teaching notes

  • Review solution notebooks in solution/ folder

  • Check error messages carefully - they often indicate the exact problem

  • Search Python documentation and community forums for specific issues

Course Feedback

Your feedback helps improve this course. Please share:

  • What topics were most helpful?

  • What could be improved?

  • What additional topics would you like to see?


Last Updated: May 2026 License: CC BY-SA 4.0