Developer Installation

This guide provides step-by-step instructions for installing the itwinai library for developers.

Cloning the Repository

When cloning the repository, you have to make sure to also clone the submodules. You can do both with the following command:

git clone [--recurse-submodules] git@github.com:interTwin-eu/itwinai.git

Creating a Virtual Environment

While not mandatory, creating a virtual environment is highly recommended to isolate dependencies and prevent conflicts with other Python projects.

Warning

On high-performance computing (HPC) systems, you must load the appropriate modules before activating your virtual environment to ensure compatibility with system libraries. See the dropdown below for detailed instructions:

HPC Systems

On HPC systems, it is common to manage dependencies using Environment Modules or Lmod. These tools allow you to dynamically load and unload software environments. If you are unsure which modules to load for your application, contact your system administrator or refer to your HPC system’s documentation for specific guidance.

For Juelich Supercomputer (JSC) and Vega Supercomputer, these are the modules you should load, depending on whether you want PyTorch or TensorFlow support:

For JSC:

ml --force purge
ml Stages/2024 GCC OpenMPI CUDA/12 cuDNN MPI-settings/CUDA
ml Python CMake HDF5 PnetCDF libaio mpi4py

For Vega:

ml --force purge
ml Python/3.11.5-GCCcore-13.2.0 CMake/3.24.3-GCCcore-11.3.0 mpi4py OpenMPI CUDA/12.3
ml GCCcore/11.3.0 NCCL cuDNN/8.9.7.29-CUDA-12.3.0 UCX-CUDA/1.15.0-GCCcore-13.2.0-CUDA-12.3.0

For JSC:

ml --force purge
ml Stages/2024 GCC/12.3.0 OpenMPI CUDA/12 MPI-settings/CUDA
ml Python/3.11 HDF5 PnetCDF libaio mpi4py CMake cuDNN/8.9.5.29-CUDA-12

For Vega:

ml --force purge
ml Python/3.11.5-GCCcore-13.2.0 CMake/3.24.3-GCCcore-11.3.0 mpi4py OpenMPI CUDA/12.3
ml GCCcore/11.3.0 NCCL cuDNN/8.9.7.29-CUDA-12.3.0 UCX-CUDA/1.15.0-GCCcore-13.2.0-CUDA-12.3.0

If you don’t already have a virtual environment, you can create one with the following command:

python -m venv <name-of-venv>

Remember to replace <name-of-venv> with the name you want for your virtual environment. Now, you can start your virtual environment with the following command:

source <name-of-venv>/bin/activate

Installing the itwinai Library as a Developer

In this project, we use uv as a project-wide package manager. Therefore, we suggest that you skim through the uv tutorial before continuing this tutorial.

Optional Dependencies (extras)

The itwinai library has numerous optional dependencies that can be activated when installing with pip through extras:

  • dev: for developers, including libraries for running tests etc.

  • torch: for installation with PyTorch support.

  • tf: for installation with TensorFlow support.

  • tf-cuda: for installation with TensorFlow support with GPU acceleration enabled.

  • docs: for installation of packages required to build the docs locally.

  • hpo: for installation of packages used for hyperparameter optimization (HPO).

You can at any point in time find (or update) the optional dependencies in the pyproject.toml file in the root of the repository.

Installing the Library Itself

As a developer, you will also install the library using pip (or uv pip if you wish), but the main difference is that you need to install it as editable using the -e flag. Another difference is that you also need the dev extra.

Note

When installing on HPC, it is sometimes an advantage to use the --no-cache-dir option to avoid filling up your ~/.cache directory. Filling up this directory will often lead to you use up your disk quota, especially in terms of inodes.

Below you can find complete commands for installation, depending on if you are installing itwinai with or without GPU (CUDA) support and locally or on HPC:

pip install -e ".[torch,dev,tf]"
pip install -e ".[torch,dev,tf]" \
    --extra-index-url https://download.pytorch.org/whl/cu121

Note: This is the same as Local (CUDA) but without using the cache directory.

pip install -e ".[torch,dev,tf]" \
    --no-cache-dir \
    --extra-index-url https://download.pytorch.org/whl/cu121

Note

If you want to use the Prov4ML logger, you need to install it explicitly since it is only available on GitHub:

For systems with Nvidia GPUs:

pip install "prov4ml[nvidia]@git+https://github.com/matbun/ProvML@new-main"

For macOS:

pip install "prov4ml[apple]@git+https://github.com/matbun/ProvML@new-main"

Installing Horovod and Microsoft DeepSpeed

If you also want to install Horovod and Microsoft DeepSpeed for distributed ML with PyTorch, then make sure to install them after itwinai. You can choose if you want to do this with or without GPU (CUDA) support:

pip install --no-cache-dir --no-build-isolation git+https://github.com/horovod/horovod.git
pip install --no-cache-dir --no-build-isolation deepspeed
curl -fsSL https://github.com/interTwin-eu/itwinai/raw/main/env-files/torch/install-horovod-deepspeed-cuda.sh | bash

Warning

Horovod requires CMake>=1.13 and other packages Make sure to have them installed in your environment before proceeding.