Skip to content

[mpi4py] [package list]

mpi4py/3.1.6-rocm-6.2.0-python-3.12-singularity-20241007 (mpi4py-3.1.6-rocm-6.2.0-python-3.12-singularity-20241007.eb)

Install with the EasyBuild-user module in partition/container:

module load LUMI partition/container EasyBuild-user
eb mpi4py-3.1.6-rocm-6.2.0-python-3.12-singularity-20241007.eb
The module will be available in all versions of the LUMI stack and in the CrayEnv stack.

To access module help after installation use module spider mpi4py/3.1.6-rocm-6.2.0-python-3.12-singularity-20241007.

EasyConfig:

easyblock = 'MakeCp'

local_version =        '3.1.6'
local_rocm_version =   '6.2.0'
local_python_version = '3.12'
local_date =           '20241007'
local_hash =           'f049c8bd4669'


name =          'mpi4py'
version =       local_version
versionsuffix = f'-rocm-{local_rocm_version}-python-{local_python_version}-singularity-{local_date}'

local_sif =    f'lumi-mpi4py-rocm-{local_rocm_version}-python-{local_python_version}-mpi4py-{local_version}-dockerhash-{local_hash}.sif'
#local_docker = 'lumi-mpi4py-rocm-5.4.5-python-3.10-mpi4py-3.1.4.docker'

homepage = 'https://github.com/mpi4py/mpi4py'

whatis = [
    'Description: MPI for Python (mpi4py) provides bindings of the Message Passing Interface (MPI) standard for the Python programming language'
]

description = """
This module provides a container with mpi4py %(version)s and cupy. 

The module defines a number of environment variables:
*   SIF and SIFMPI4PY: The full path and name of the Singularity SIF file 
    to use with singularity exec etc.
*   SINGULARITY_BIND: Mounts the necessary directories from the system,
    including /users, /project, /scratch and /flash so that you should be
    able to use your regular directories in the container.
*   RUNSCRIPTS and RUNSCRIPTSMPI4PY: The directory with some sample
    runscripts.


Note that this container uses a Conda environment internally. When in
the container, the command to activate the container is contained in the
environment variable WITH_CONDA.
"""

docurls = [
    'mpi4py web-based manual: https://mpi4py.readthedocs.io/en/'
]

toolchain = SYSTEM

sources = [
    {
        'filename':    local_sif,
        'extract_cmd': '/bin/cp %s .'
    },
#    {
#        'filename':    local_docker,
#        'extract_cmd': '/bin/cp %s .'
#    },
]

skipsteps = ['build']

files_to_copy = [
    ([local_sif],    '.'),
#    ([local_docker], 'share/docker-defs/')    
]

local_runscript_python_simple="""
#!/bin/bash -e

# Start conda environment inside the container
\$WITH_CONDA

# Run application
python "\$@"

"""

local_bin_start_shell="""
#!/bin/bash -e

# Run application
if [[ -f "/.singularity.d/Singularity" ]] 
then
    # In a singularity container, just in case a user would add this to the path.
    exec bash "\$@"
else
    # Not yet in the container
    singularity exec \$SIFMPI4PY bash "\$@"
fi

"""

postinstallcmds = [
    'mkdir -p %(installdir)s/runscripts',
    f'cat >%(installdir)s/runscripts/conda-python-simple <<EOF {local_runscript_python_simple}EOF',
    'chmod a+x %(installdir)s/runscripts/conda-python-simple',
    'mkdir -p %(installdir)s/bin',
    f'cat >%(installdir)s/bin/start-shell <<EOF {local_bin_start_shell}EOF',
    'chmod a+x %(installdir)s/bin/start-shell',
]

sanity_check_paths = {
    # We deliberately don't check for local_sif as the user is allowed to remove that file
    # but may still want to regenerate the module which would then fail in the sanity check.
    #'files': [f'share/docker-defs/{local_docker}'],
    'files': ['bin/start-shell', 'runscripts/conda-python-simple'],
    'dirs':  [],
}

modextravars = {
    # SIF variables currently set by a function via modluafooter.
    #'SIF':             '%(installdir)s/' + local_sif,
    #'SIFMPI4PY':       '%(installdir)s/' + local_sif,
    'RUNSCRIPTS':       '%(installdir)s/runscripts',
    'RUNSCRIPTSMPI4PY': '%(installdir)s/runscripts',
    'SINGULARITY_BIND': '/var/spool/slurmd,/opt/cray,/usr/lib64/libcxi.so.1,' +
                        '%(installdir)s/runscripts:/runscripts,' + 
                        '/pfs,/scratch,/projappl,/project,/flash,/appl'
}

modluafooter = f"""
-- Call a routine to set the various environment variables.
create_container_vars( '{local_sif}', 'mpi4py', '%(installdir)s' )
"""

moduleclass = 'devel'

[mpi4py] [package list]