| Next revision | Previous revision |
| habrok:software_environment:python:loading_python [2026/04/07 12:51] – created pedro | habrok:software_environment:python:loading_python [2026/10/23 08:24] (current) – Fix link pedro |
|---|
| | |
| <WRAP center round tip> | <WRAP center round tip> |
| **TLDR** | **TL;DR** |
| |
| If you need to use a specific Python library on Hábrók, check if it already available before installing it in your user directories ''pip install''. Using the cluster-provided modules may be possible and these are compiled and optimised for the hardware so it can significantly speed up your computation. First, check whether the library is already available from the specific version of Python you loaded. If it is not, check whether the library is installed on Hábrók as a module with ''module avail library_name''. However, if the version you need is not available, which can happen with fast-moving libraries like TensorFlow, installing it yourself in a virtual environment is the right approach (see the [[habrok_internal:drafts:python:environments|Python Environments]] page). | If you need to use a specific Python library on Hábrók, check if it already available before installing it in your user directories ''pip install''. Using the cluster-provided modules may be possible and these are compiled and optimised for the hardware so it can significantly speed up your computation. First, check whether the library is already available from the specific version of Python you loaded. If it is not, check whether the library is installed on Hábrók as a module with ''module avail library_name''. However, if the version you need is not available, which can happen with fast-moving libraries like TensorFlow, installing it yourself in a virtual environment is the right approach (see the [[habrok_internal:drafts:python:environments|Python Environments]] page). |
| | |
| The Python ecosystem is extremely varied, with a lot of libraries for all sorts of purposes, from web servers, to numerical computing, and everything in between and to the sides. | The Python ecosystem is extremely varied, with a lot of libraries for all sorts of purposes, from web servers, to numerical computing, and everything in between and to the sides. |
| | |
| As a Python user, you would usually install these libraries with ''pip'', the Python Package Installer. You can still do that on Hábrók, as we have detailed in the [[habrok_internal:drafts:python:environments:pip_venv|pip + venv]] page, but this is not always the best way, because ''pip'' doesn't optimize the libraries for the particular machines they would be running on. In an HPC environment, performance is key, especially for numerical libraries. | As a Python user, you would usually install these libraries with ''pip'', the Python Package Installer. You can still do that on Hábrók, as we have detailed in the [[environments#pip_venv|pip + venv]] section, but this is not always the best way, because ''pip'' doesn't optimize the libraries for the particular machines they would be running on. In an HPC environment, performance is key, especially for numerical libraries. |
| | |
| The Python module itself comes with a host of libraries already installed (optimally), so that is the first place to look for a specific library. You can check what is included with: | The Python module itself comes with a host of libraries already installed (optimally), so that is the first place to look for a specific library. You can check what is included with: |
| </code> | </code> |
| |
| Notice that even though we previously loaded ''Python/3.13.5-GCCcore-14.3.0'', loading TensorFlow has replaced it with ''Python/3.10.4-GCCcore-11.3.0''. This is expected behaviour since TensorFlow was built against a specific Python version and the module system automatically loads the compatible version. This is a general rule: when you load a library module, it will bring in the Python version it was built against, regardless of what you loaded before. It is therefore important to be aware of which Python version is actually active after loading all your modules, which you can always check with ''python3 --version''. | Notice that even though we previously loaded ''Python/3.13.5-GCCcore-14.3.0'', loading TensorFlow has replaced it with ''Python/3.10.4-GCCcore-11.3.0''. This is expected behaviour since TensorFlow was built against a specific Python version and the module system automatically loads the compatible version. This is a general rule: when you load a library module, it will bring in the Python version it was built against, regardless of what you loaded before. It is therefore important to be aware of which Python version is actually active after loading all your modules, which you can always check with ''python3 %%--%%version''. |
| <code> | <code> |
| The following have been reloaded with a version change: | The following have been reloaded with a version change: |